Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Apache Luncen SpellChecker in core java code

user13534632Dec 23 2010 — edited Dec 23 2010
HI..

upto now i done like this can u suggest me..and but i didnt get result from this


package com.spellchecker;

import java.io.File;

import javax.xml.ws.soap.Addressing;

import org.apache.lucene.search.spell.PlainTextDictionary;
import org.apache.lucene.search.spell.SpellChecker;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

public class SpellCheckerExample {

public static void main(String[] args) throws Exception {

String wordForSuggestions = "hwllo";
int suggestionsNumber = 5;

File dir = new File("D:/spellchecker/");
Directory directory = FSDirectory.open(dir);



SpellChecker spellChecker = new SpellChecker(directory);
spellChecker.indexDictionary(
new PlainTextDictionary(new File("D:/dictionary.txt")));
String[] suggestions = spellChecker.
suggestSimilar(wordForSuggestions, suggestionsNumber);

if (suggestions!=null && suggestions.length>0) {
for (String word : suggestions) {
System.out.println("Did you mean:" + word);
}
}
else {
System.out.println("No suggestions found for word:"+wordForSuggestions);
}

}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 20 2011
Added on Dec 23 2010
11 comments
426 views