Porter stemmer gives different results when calculating semantic similarity

147 views Asked by At

I am making some tests with ws4j library. In particular I want to calculate similarity between two test words "university" and "teaching". When I apply stemming, it gives me 0 similarity... When I do not apply stemming, the result is higher than 0. On the other hand, when I check the similarity between "genders" and "sex", then stemming has a reverse impact: when I use it, it gives a positive similarity. Otherwise the similarity is equal to 0.

Why does it happen and which would be a more generic approach that would give similar results for both examples?

public class TestWs4j
{    
    private static ILexicalDatabase db = new NictWordNet();
    private static RelatednessCalculator[] rcs = {
            new WuPalmer(db), // new HirstStOnge(db), new LeacockChodorow(db), new Lesk(db),
            new JiangConrath(db), new Path(db) // new Resnik(db), new Lin(db),
    };

    private static void run( String word1, String word2 ) {
        WS4JConfiguration.getInstance().setMFS(true);
        for ( RelatednessCalculator rc : rcs ) {
            double s = rc.calcRelatednessOfWords(word1, word2);
            System.out.println( rc.getClass().getName()+"\t"+s );
        }
    }
    public static void main(String[] args) {
        long t0 = System.currentTimeMillis();
        PorterStemmer stemmer = new PorterStemmer();
//        String w1 = stemmer.stemWord("university");
//        String w2 = stemmer.stemWord("teaching");
//        run(w1,w2);
        run("university","teaching");
        long t1 = System.currentTimeMillis();
        System.out.println( "Done in "+(t1-t0)+" msec." );
    }
}
0

There are 0 answers