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);
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations