Wordnet Similarity in Java: JAWS, JWNL or Java WN::Similarity?

别等时光非礼了梦想. 提交于 2019-11-26 20:29:02

问题


I need to use Wordnet in a java-based app. I want to:

  • search synsets

  • find similarity/relatedness between synsets

My app uses RDF graphs and I know there are SPARQL endpoints with Wordnet, but I guess it's better to have a local copy of the dataset, as it's not too big.

I've found the following jars:

  • General library - JAWS http://lyle.smu.edu/~tspell/jaws/index.html
  • General library - JWNL http://sourceforge.net/projects/jwordnet
  • Similarity library (Perl) - Wordnet::similarity http://wn-similarity.sourceforge.net/
  • Java version of Wordnet::similarity http://www.cogs.susx.ac.uk/users/drh21/ (beta)

What would you recommend for my app?

Is it possible to use a Perl library from a java app via some bindings?

Thanks! Mulone


回答1:


I use JAWS for normal wordnet stuff because it's easy to use. For similarity metrics, though, I use the library located here. You'll also need to download this folder, containing pre-processed WordNet and corpus data, for it to work. The code can be used like this, assuming you placed that folder in another called "lib" in your project folder:

JWS ws = new JWS("./lib", "3.0");
Resnik res = ws.getResnik();
TreeMap<String, Double> scores1 = res.res(word1, word2, partOfSpeech);
for(Entry<String, Double> e: scores1.entrySet())
    System.out.println(e.getKey() + "\t" + e.getValue());
System.out.println("\nhighest score\t=\t" + res.max(word1, word2, partOfSpeech) + "\n\n\n");

This will print something like the following, showing the similarity score between each possible combination of synsets represented by the words to be compared:

hobby#n#1,gardening#n#1 2.6043996588901104
hobby#n#2,gardening#n#1 -0.0
hobby#n#3,gardening#n#1 -0.0
highest score   =   2.6043996588901104

There are also methods that allow you to specify which sense of either/both words: res(String word1, int senseNum1, String word2, partOfSpeech), etc. Unfortunately, the source documentation is not JavaDoc, so you'll need to inspect it manually. The source can be downloaded here.

The available algorithms are:

JWSRandom(ws.getDictionary(), true, 16.0);//random number for baseline
Resnik res = ws.getResnik();
LeacockAndChodorowlch = ws.getLeacockAndChodorow();
AdaptedLesk adLesk = ws.getAdaptedLesk();
AdaptedLeskTanimoto alt = ws.getAdaptedLeskTanimoto();
AdaptedLeskTanimotoNoHyponyms altnh = ws.getAdaptedLeskTanimotoNoHyponyms();
HirstAndStOnge hso = ws.getHirstAndStOnge();
JiangAndConrath jcn = ws.getJiangAndConrath();
Lin lin = ws.getLin();
WuAndPalmer wup = ws.getWuAndPalmer();

Also, it requires you to have the jar file for MIT's JWI




回答2:


There is function in JAWS to find similar wordForms Here are details:

public AdjectiveSynset[] getSimilar() throws WordNetException and here is link that you can check out: http://lyle.smu.edu/~tspell/jaws/doc/edu/smu/tspell/wordnet/AdjectiveSynset.html this link it contails details that you can use.




回答3:


I am not sure if either JAWS or JWNL provide methods to calculate similarity between synsets, but I have tried both for searching synsets and I've found JAWS easier to use. Specifically, the simple:

    // Specifying the Database Directory
    System.setProperty("wordnet.database.dir", "C:/WordNet/2.1/dict/");

was easier for me to understand than JWNL's file_properties.xml requirement.



来源:https://stackoverflow.com/questions/5976537/wordnet-similarity-in-java-jaws-jwnl-or-java-wnsimilarity

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