i'm trying to search synonym(which i declare as 'synset') recursively. Unfortunately, there are duplicate of synonym. For example: when i search the word student, the output will be like this:
Search word: student
Synset 0: pupil
Synset 0: student
Synset 0: pupil
.
.
.
Synset 1: educatee
Synset 2: schoolchild
Synset 1: educatee
Synset 2: scholar
Synset 3: bookman
I want to store all the output into database and I do not need the duplicate output.This is part of my code that consist recursive function. Hope anyone can help me..Thanks
public String printSynset(String word)
{
//call wordnet library
RiWordnet wordnet = new RiWordnet();
//call stemmer method
PorterStemmer s = new PorterStemmer();
Vector<String> synsetVec = new Vector<String>();
String[] synset = wordnet.getAllSynsets(word, "n");
for (int k=0; k<synset.length; k++)
{
synsetVec.add(synset[k]);
if (!synsetVec.isEmpty())
{
for (int j = 0; j < synsetVec.size();)
{
GUIsynonymTA.append("\n");
GUIsynonymTA.append(" No." + j + ": " + (s.Stem(synsetVec.get(j))));
GUIsynonymTA.append("\n");
return printSynset(synsetVec.get(j));
}
}
else if (synsetVec.isEmpty())
return word;
}
return word;
}//end printSynset()
if (!sysnsetVec.isEmpty())and then anelse if (sysncVec.isEmpty()). If theifreturns false you can just do anelse.