
com.jaeksoft.searchlib.webservice.query.spellcheck.SpellcheckResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opensearchserver Show documentation
Show all versions of opensearchserver Show documentation
OpenSearchServer is a powerful, enterprise-class, search engine program. Using the web user interface,
the crawlers (web, file, database, ...) and the REST/RESTFul API you will be able to integrate quickly and
easily advanced full-text search capabilities in your application. OpenSearchServer runs on Windows and
Linux/Unix/BSD.
/**
* License Agreement for OpenSearchServer
*
* Copyright (C) 2011-2013 Emmanuel Keller / Jaeksoft
*
* http://www.open-search-server.com
*
* This file is part of OpenSearchServer.
*
* OpenSearchServer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenSearchServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenSearchServer.
* If not, see .
**/
package com.jaeksoft.searchlib.webservice.query.spellcheck;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.jaeksoft.searchlib.result.ResultSpellCheck;
import com.jaeksoft.searchlib.spellcheck.SpellCheck;
import com.jaeksoft.searchlib.spellcheck.SpellCheckItem;
import com.jaeksoft.searchlib.spellcheck.SuggestionItem;
import com.jaeksoft.searchlib.webservice.CommonResult;
@XmlRootElement(name = "result")
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class SpellcheckResult extends CommonResult {
@XmlElement(name = "field")
public List fields;
public SpellcheckResult() {
fields = null;
}
public SpellcheckResult(ResultSpellCheck result, String query) {
List spellChecks = result.getSpellCheckList();
if (spellChecks == null)
return;
fields = new ArrayList(spellChecks.size());
for (SpellCheck spellCheck : spellChecks)
fields.add(new Field(spellCheck));
}
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlType(name = "SpellcheckField")
public static class Field {
@XmlElement(name = "fieldName")
public String fieldName;
@XmlElement(name = "word")
public List words;
public String suggestion;
public Field() {
words = null;
fieldName = null;
}
public Field(SpellCheck spellCheck) {
fieldName = spellCheck.getFieldName();
List spellCheckItems = spellCheck.getList();
if (spellCheckItems == null)
return;
words = new ArrayList(spellCheckItems.size());
for (SpellCheckItem spellCheckItem : spellCheckItems)
words.add(new Word(spellCheckItem));
suggestion = spellCheck.getSuggestion();
}
}
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public static class Word {
@XmlElement(name = "word")
public String word;
@XmlElement(name = "suggest")
public List suggest;
public Word() {
word = null;
suggest = null;
}
public Word(SpellCheckItem spellItem) {
word = spellItem.getWord();
SuggestionItem[] suggestions = spellItem.getSuggestions();
if (suggestions == null)
return;
suggest = new ArrayList(suggestions.length);
for (SuggestionItem suggestion : suggestions)
suggest.add(new Suggestion(suggestion));
}
}
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public static class Suggestion {
@XmlElement(name = "term")
public String term;
@XmlElement(name = "freq")
public int freq;
public Suggestion() {
term = null;
freq = 0;
}
public Suggestion(SuggestionItem suggestionItem) {
term = suggestionItem.getTerm();
freq = suggestionItem.getFreq();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy