Search in sources :

Example 1 with Chunk

use of de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk in project webanno by webanno.

the class ChunkLayerInitializer method configure.

@Override
public void configure(Project aProject) throws IOException {
    AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true);
    chunkLayer.setAllowStacking(false);
    chunkLayer.setMultipleTokens(true);
    chunkLayer.setLockToTokenOffset(false);
    annotationSchemaService.createLayer(chunkLayer);
    AnnotationFeature chunkValueFeature = new AnnotationFeature();
    chunkValueFeature.setDescription("Chunk tag");
    chunkValueFeature.setName("chunkValue");
    chunkValueFeature.setType(CAS.TYPE_NAME_STRING);
    chunkValueFeature.setProject(aProject);
    chunkValueFeature.setUiName("Tag");
    chunkValueFeature.setLayer(chunkLayer);
    annotationSchemaService.createFeature(chunkValueFeature);
}
Also used : AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Chunk(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 2 with Chunk

use of de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk in project dkpro-tc by dkpro.

the class DiffNounChunkCharacterLengthTest method extractTest1.

@Test
public void extractTest1() throws Exception {
    Chunk chunk1 = new Chunk(jcas1, 0, 4);
    chunk1.addToIndexes();
    Chunk chunk2 = new Chunk(jcas2, 0, 4);
    chunk2.addToIndexes();
    DiffNounChunkCharacterLength extractor = new DiffNounChunkCharacterLength();
    Set<Feature> features = extractor.extract(jcas1, jcas2);
    assertEquals(1, features.size());
    for (Feature feature : features) {
        FeatureTestUtil.assertFeature("DiffNounPhraseCharacterLength", 0.0, feature, 0.0001);
    }
}
Also used : DiffNounChunkCharacterLength(org.dkpro.tc.features.pair.core.chunk.DiffNounChunkCharacterLength) Chunk(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk) FeatureTestUtil.assertFeature(org.dkpro.tc.testing.FeatureTestUtil.assertFeature) Feature(org.dkpro.tc.api.features.Feature) Test(org.junit.Test)

Example 3 with Chunk

use of de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk in project dkpro-tc by dkpro.

the class DiffNounChunkCharacterLengthTest method extractTest2.

@Test
public void extractTest2() throws Exception {
    Chunk chunk1 = new Chunk(jcas1, 0, 4);
    chunk1.addToIndexes();
    Chunk chunk2 = new Chunk(jcas2, 0, 7);
    chunk2.addToIndexes();
    DiffNounChunkCharacterLength extractor = new DiffNounChunkCharacterLength();
    Set<Feature> features = extractor.extract(jcas1, jcas2);
    assertEquals(1, features.size());
    for (Feature feature : features) {
        assertFeature("DiffNounPhraseCharacterLength", -3.0, feature, 0.0001);
    }
}
Also used : DiffNounChunkCharacterLength(org.dkpro.tc.features.pair.core.chunk.DiffNounChunkCharacterLength) Chunk(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk) FeatureTestUtil.assertFeature(org.dkpro.tc.testing.FeatureTestUtil.assertFeature) Feature(org.dkpro.tc.api.features.Feature) Test(org.junit.Test)

Example 4 with Chunk

use of de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk in project webanno by webanno.

the class LegacyProjectInitializer method createChunkLayer.

private void createChunkLayer(Project aProject) throws IOException {
    AnnotationLayer chunkLayer = new AnnotationLayer(Chunk.class.getName(), "Chunk", SPAN_TYPE, aProject, true);
    chunkLayer.setAllowStacking(false);
    chunkLayer.setMultipleTokens(true);
    chunkLayer.setLockToTokenOffset(false);
    annotationSchemaService.createLayer(chunkLayer);
    AnnotationFeature chunkValueFeature = new AnnotationFeature();
    chunkValueFeature.setDescription("Chunk tag");
    chunkValueFeature.setName("chunkValue");
    chunkValueFeature.setType(CAS.TYPE_NAME_STRING);
    chunkValueFeature.setProject(aProject);
    chunkValueFeature.setUiName("Tag");
    chunkValueFeature.setLayer(chunkLayer);
    annotationSchemaService.createFeature(chunkValueFeature);
}
Also used : AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Chunk(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 5 with Chunk

use of de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk in project dkpro-tc by dkpro.

the class SharedNounChunks method getSharedNounChunksCount.

/**
 * Computes the ratio of shared nouns
 *
 * @param view1
 *            First view to be processed
 * @param view2
 *            Second view to be processed
 * @return The quotient of shared noun chunks in both views and noun chunks in the first view
 */
private double getSharedNounChunksCount(JCas view1, JCas view2) {
    Set<String> chunks1 = new HashSet<String>();
    for (Chunk chunk : JCasUtil.select(view1, Chunk.class)) {
        chunks1.add(chunk.getCoveredText());
    }
    Set<String> chunks2 = new HashSet<String>();
    for (Chunk chunk : JCasUtil.select(view2, Chunk.class)) {
        chunks2.add(chunk.getCoveredText());
    }
    chunks1.retainAll(chunks2);
    Double result = chunks1.size() / (double) JCasUtil.select(view1, Chunk.class).size();
    return result.equals(Double.NaN) ? 0. : result;
}
Also used : Chunk(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk) HashSet(java.util.HashSet)

Aggregations

Chunk (de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk)7 Feature (org.dkpro.tc.api.features.Feature)4 FeatureTestUtil.assertFeature (org.dkpro.tc.testing.FeatureTestUtil.assertFeature)4 Test (org.junit.Test)4 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 DiffNounChunkCharacterLength (org.dkpro.tc.features.pair.core.chunk.DiffNounChunkCharacterLength)2 DiffNounChunkTokenLength (org.dkpro.tc.features.pair.core.chunk.DiffNounChunkTokenLength)2 HashSet (java.util.HashSet)1