lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leandro <leandro.rhc...@gmail.com>
Subject Questions about use of SpellChecker: Constructor and Simillarity...
Date Tue, 08 Apr 2008 15:57:37 GMT
Hi,

I have two question about this GREAT tool.. (framework, library...
"whatever")
Well I decide put spell checker on my applications and I start to read some
papers and "found out" the Lucene project...

Anyway, I make it works, but I just want to know...

1º Why need I pass a Directory objecto (obligatory) on constructor of
SpellChecker?
2º Suposse that in my dictonary I had these words:

"The Lord of the Rings: The Two Towers"
"The Lord of the Rings: The Fellowship of the Ring"
"The Lord of the Rings: The Return of the King"

I just want to know how can I code something to "suggest" when user query
"The Lord of the Rings: The Two Towers" the application suggest:

"The Lord of the Rings: The Fellowship of the Ring"
"The Lord of the Rings: The Return of the King"

It is possible just using the Lucene?

################ My Test Class ######################
SpellChecker spell;
spell= new SpellChecker(FSDirectory.getDirectory(".")); //why this... ?!!
spell.indexDictionary(new Dicionario());

String[] l = spell.suggestSimilar(args[0],5);

for (String vl : l ){
   System.out.println("Suggested : " + vl);
}
###############################################



############### My Dictionary######################
public class Dicionario implements
org.apache.lucene.search.spell.Dictionary{

public Iterator getWordsIterator(){
        List<String> lista = new ArrayList<String>();
        lista.add("peter");
        lista.add("spider man 3");
        lista.add("johnny depp");
        lista.add("the edge");
        lista.add("monk");
        lista.add("arnold schwarzenegger");
        return lista.iterator();
    }
}
###############################################

Thanks in advance... :D

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message