i'm using linkedhashset to store my synonym list. if there is synonym for my search word, some statement will be done. However, when there is no synonym for my search word, some errors will occur. Below is part of my program.
String[] synset = wordnet.getAllSynsets(keyword, "n");
Set<String> synsetVec = new LinkedHashSet<String>();
for (int k = 0; k < synset.length; k++) {
//store synonym in synsetVec
synsetVec.add(s.Stem(synset[k]));
System.out.println("SynsetVec = " + synsetVec);
if (!synsetVec.isEmpty()) {
//do something here
} else {
GUIsynonymTA.append("No synsets");
}
}
This error "java.lang.NullPointerException" occur when no synset for the search word. Can anyone help me? Thanks in advance.