-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Detecting Languages for Spellchecker feature
PostPosted: Sun Jun 11, 2017 6:42 pm 
Newbie

Joined: Wed Jun 07, 2017 3:21 pm
Posts: 4
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);
   }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.