How can I find synonyms in estimated frequency order using JWNL(Wordnet Library)?

扶醉桌前 提交于 2019-12-10 12:55:38

问题


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]); }
                }
           }
     }

回答1:


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 :)



来源:https://stackoverflow.com/questions/13822141/how-can-i-find-synonyms-in-estimated-frequency-order-using-jwnlwordnet-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!