我将JAWS用于普通的wordnet东西,因为它易于使用。不过,对于相似性指标,我使用此处的库。您还需要下载此文件夹,其中包含经过预处理的WordNet和语料库数据,才能正常工作。假设您将该文件夹放置在项目文件夹中的另一个名为“
lib”的文件夹中,则可以像这样使用代码:
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 scoret=t" + res.max(word1, word2, partOfSpeech) + "nnn");这将打印如下内容,显示由要比较的单词表示的同义词集的每种可能组合之间的相似性得分:
hobby#n#1,gardening#n#1 2.6043996588901104hobby#n#2,gardening#n#1 -0.0hobby#n#3,gardening#n#1 -0.0highest score = 2.6043996588901104
还有一些方法可以让您指定两个单词中的任一个或两个:
res(String word1, int senseNum1, String word2,partOfSpeech)等等。不幸的是,源文档不是JavaDoc,因此您需要手动检查它。可以在这里下载源代码。
可用的算法有:
JWSRandom(ws.getDictionary(), true, 16.0);//random number for baselineResnik 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();
另外,它要求您拥有MIT的JWI的jar文件



