ws4j returns values greater than 1 for wu and palmer measurement

0

The code should calculate the similarity measure of Wu and Palmer that is between 0 and 1, but returns values above 1. I have already tried to do it in other ways (with small changes) and all give values different from that calculated in ws4jdemo. appspot.com

public class WordsSimilarity{
    public static void main(String[] args) {
    ILexicalDatabase db = new NictWordNet();
    RelatednessCalculator rc = new WuPalmer(db);
    String word1="cancer";
    POS posWord1=  POS.n;
    String word2= "disease";
    POS posWord2= POS.n;
    double maxScore = 0;


    try {
        WS4JConfiguration.getInstance().setMFS(true);

        List<Concept> synsets1 = (List<Concept>)db.getAllConcepts(word1, posWord1.name());
        List<Concept> synsets2 = (List<Concept>)db.getAllConcepts(word2, posWord2.name());

        for(Concept synset1: synsets1) {
            for (Concept synset2: synsets2) {
                Relatedness relatedness = rc.calcRelatednessOfSynset(synset1, synset2); 
                double score = relatedness.getScore();
                if (score > maxScore) { 
                    maxScore = score;
                }
            }
        }

    }
    catch(Exception e) {

    }
    if (maxScore == -1D) {
        maxScore = 0.0;
    }

    System.out.println("Similarity score of " + word1 + " & " + word2 + " : " + maxScore);
    }
    
asked by anonymous 30.01.2018 / 00:47

0 answers