Does anyone know how I can take the synonyms of a word using JWNL (Java Wordnet Library) ordered by estimated frequency? I know this can be done somehow, because Wordnet's application can do it. (I don't know if it matters, but I am using Wordnet 2.1)
Here is my code of how I get synonyms, could anyone please tell me what I should add... (completely different ways of doing it are also welcomed!)
ArrayList<String> synonyms=new ArrayList<String>();
System.setProperty("wordnet.database.dir", filepath);
String wordForm = "make";
Synset[] synsets = database.getSynsets(wordForm,SynsetType.VERB);
if (synsets.length > 0) {
for (int i = 0; i < synsets.length; i++) {
String[] wordForms = synsets[i].getWordForms();
for (int j = 0; j < wordForms.length; j++) {
if(!synonyms.contains(wordForms[j])){
synonyms.add(wordForms[j]); }
}
}
}
Since noone answered, I suppose there must be more people wondering the same think and not knowing the answer.
Well, I figured out that there is the function Synset.getTagCount(String), which returns the value of the estimated frequency of every synset relating to the word(String). So, all I had to do was to sort the ArrayList with the synonyms according to this.
But it was proved that the synsets are by default returned sorted, so what I get using the code I wrote at the question is already ordered by estimated frequency!
I hope this will help somebody in the future :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With