我正在使用WS4j来查找两个单词之间的相似性。我也在使用Wu-Palmer相关性计算器。它适用于许多单词,但是当我试图找到“播放”之间的相似性时。并且' play',它给出得分1.3333,这是不可能的,因为它必须在0和1或-1之间返回。我无法弄清楚原因。 当我使用其网络界面' http://ws4jdemo.appspot.com/?mode=w&s1=&w1=play&s2=&w2=playing'它返回0.875。 这是我的代码:
private static void findSimilarity(String word1, String word2) {
WS4JConfiguration.getInstance().setMFS(true);
List<POS[]> posPairs = wup.getPOSPairs();
double maxScore = -1D;
for(POS[] posPair: posPairs) {
List<Concept> synsets1 =
(List<Concept>)db.getAllConcepts(word1, posPair[0].toString());
List<Concept> synsets2 =
(List<Concept>)db.getAllConcepts(word2, posPair[1].toString());
for(Concept synset1: synsets1) {
for (Concept synset2: synsets2) {
Relatedness relatedness = wup.calcRelatednessOfSynset(synset1, synset2);
double score = relatedness.getScore();
if (score > maxScore) {
maxScore = score;
}
}
}
}
if (maxScore == -1D) {
maxScore = 0.0;
}
System.out.println("sim('" + word1 + "', '" + word2 + "') = " + maxScore);
}