Search in sources :

Example 1 with GreedyStringTilingFeatureExtractor

use of org.dkpro.tc.features.pair.similarity.GreedyStringTilingFeatureExtractor in project dkpro-tc by dkpro.

the class GreedyStringTilingFeatureExtractorTest method greedyStringTilingFeatureExtractorTest.

@Test
public void greedyStringTilingFeatureExtractorTest() throws Exception {
    AnalysisEngine engine = createEngine(NoOpAnnotator.class);
    JCas jcas = engine.newJCas();
    jcas.setDocumentLanguage("en");
    jcas.setDocumentText("1234567890");
    engine.process(jcas);
    JCas jcas2 = engine.newJCas();
    jcas2.setDocumentLanguage("en");
    jcas2.setDocumentText("12345");
    engine.process(jcas2);
    GreedyStringTilingFeatureExtractor extractor = new GreedyStringTilingFeatureExtractor();
    Set<Feature> features1 = extractor.extract(jcas, jcas2);
    assertEquals(1, features1.size());
    Feature f1 = features1.iterator().next();
    assertEquals(f1.getValue(), 0.5);
}
Also used : GreedyStringTilingFeatureExtractor(org.dkpro.tc.features.pair.similarity.GreedyStringTilingFeatureExtractor) JCas(org.apache.uima.jcas.JCas) Feature(org.dkpro.tc.api.features.Feature) AnalysisEngine(org.apache.uima.analysis_engine.AnalysisEngine) Test(org.junit.Test)

Aggregations

AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)1 JCas (org.apache.uima.jcas.JCas)1 Feature (org.dkpro.tc.api.features.Feature)1 GreedyStringTilingFeatureExtractor (org.dkpro.tc.features.pair.similarity.GreedyStringTilingFeatureExtractor)1 Test (org.junit.Test)1