Hi all,
i implemented the spellcheker feature in lucene full text serach engine.
in the search feature i have the possibility to type the keyword in 3 languages: english, frensh, and arabic.
i implemented 3 methods: getSuggestionsEn, getSuggestionsFr and getSuggestionsAr, depending on the language i execute a method
so how can i detect the language of the typed keyWord ?
Code:
public List<String> getSuggestionsEn(String keyWord) {
String[] suggestions = new String[] {};
try {
Directory directory = FSDirectory.open(new File("/app/lucene/spellchecker/com.axeleate.marketplace.model.category.ProductEn"));
SpellChecker spellChecker = new SpellChecker(directory);
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_36, new EnglishAnalyzer(Version.LUCENE_36));
spellChecker.setStringDistance(new LevensteinDistance());
spellChecker.indexDictionary(new PlainTextDictionary(new File("/app/fulldictionary00.txt")),indexWriterConfig, true);
suggestions = spellChecker.suggestSimilar(keyWord.toLowerCase(), 10);
} catch (Exception e) {
e.printStackTrace();
}
return Arrays.asList(suggestions);
}