TypeTokenRatioComparator ----Stylistic Similarity (Package dkpro.similarity.algorithms.style)

6 views
Skip to first unread message

Farjana Khan

unread,
Mar 12, 2018, 9:55:55 AM3/12/18
to DKPro Similarity Users

I got Similarity Score like this: NaN

My Code:

 String text1= "i am going to school";
 String  text2= "i am going";

        JCas JCas1 =JCasFactory.createJCas();
        JCas1.setDocumentLanguage("en");
        JCas1.setDocumentText(text1);
       
        JCas JCas2 = JCasFactory.createJCas();
        JCas2.setDocumentLanguage("en");
        JCas2.setDocumentText(text2);
                   
         Annotation a1 = new Annotation(JCas1);
         a1.setBegin(0);
         a1.setEnd(text1.length());
         Annotation a2 = new Annotation(JCas2);
         a2.setBegin(0);
         a2.setEnd(text2.length());

TypeTokenRatioComparator comparator=new TypeTokenRatioComparator();   
       
       
        double result = 0.0;
       
        try {
           
            result =comparator.getSimilarity( JCas1,JCas2,a1,a2);          
           
           
        } catch (SimilarityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
        system.out.print(result);
    }
Here is take TypeTokenRatioComparator class.Could you give me some info what is the actual ?
actually i  want get similarity by using this class. still now i have not clear info how to call

TypeTokenRatioComparator.getSimilarity(JCas jcas1, JCas jcas2, Annotation coveringAnnotation1,  
          Annotation coveringAnnotation2)

Please help me.....



Torsten Zesch

unread,
Mar 12, 2018, 10:00:30 AM3/12/18
to Farjana Khan, DKPro Similarity Users
This comparator requires Token and Lemma annotations. If you create them accordingly, instead of the untyped "Annotation"s this should work.

-Torsten

ps: requiring lemmas sounds like a bit too much actually. Maybe the implementation should be changed in this point. However, token annotations are definitely needed.




--
You received this message because you are subscribed to the Google Groups "DKPro Similarity Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dkpro-similarity-users+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages