use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testZeroLengthSpansWithFeatureValues.
@Test
public void testZeroLengthSpansWithFeatureValues() throws Exception {
JCas jcas = makeJCasOneSentence();
// One at the beginning
NamedEntity ne1 = new NamedEntity(jcas, 0, 0);
ne1.setValue("PERSON");
ne1.addToIndexes();
// One at the end
NamedEntity ne2 = new NamedEntity(jcas, jcas.getDocumentText().length(), jcas.getDocumentText().length());
ne2.setValue("ORG");
ne2.addToIndexes();
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testTokenBoundedStackedSpanWithFeatureValue.
@Test
public void testTokenBoundedStackedSpanWithFeatureValue() throws Exception {
JCas jcas = makeJCasOneSentence();
for (Token t : select(jcas, Token.class)) {
NamedEntity ne1 = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne1.setValue("NE");
ne1.addToIndexes();
NamedEntity ne2 = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne2.setValue("NE");
ne2.addToIndexes();
}
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testSubMultiTokenSpanWithFeatureValue.
@Test
public void testSubMultiTokenSpanWithFeatureValue() throws Exception {
JCas jcas = makeJCasOneSentence("aaaaaa bbbbbb cccccc");
assertEquals(asList("aaaaaa", "bbbbbb", "cccccc"), toText(select(jcas, Token.class)));
// 1111111111
// 01234567890123456789
// --------------------
// aaaaaa bbbbbb cccccc
// 1 ------ - single token
// 2 ------+------ - multi-token
// 3 -- - inside token
// 4 ---- - token prefix
// 5 ---- - token suffix
// 6 ---+------ - multi-token prefix
// 7 ------+--- - multi-token suffix
// 8 ---+--- - multi-token prefix + suffix
// 9 ---+------+--- - multi-token prefix + full + suffix
// 10 | - zero-span inside token
// 11 | - zero-span beginning of token
// 12 | - zero-span end of token
List<NamedEntity> annotations = new ArrayList<>();
// 1
annotations.add(new NamedEntity(jcas, 0, 6));
// 2
annotations.add(new NamedEntity(jcas, 0, 13));
// 3
annotations.add(new NamedEntity(jcas, 9, 11));
// 4
annotations.add(new NamedEntity(jcas, 7, 11));
// 5
annotations.add(new NamedEntity(jcas, 9, 13));
// 6
annotations.add(new NamedEntity(jcas, 3, 13));
// 7
annotations.add(new NamedEntity(jcas, 0, 10));
// 8
annotations.add(new NamedEntity(jcas, 3, 10));
// 9
annotations.add(new NamedEntity(jcas, 3, 17));
// 10
annotations.add(new NamedEntity(jcas, 10, 10));
// 11
annotations.add(new NamedEntity(jcas, 7, 7));
// 12
annotations.add(new NamedEntity(jcas, 13, 13));
IntStream.range(0, annotations.size()).forEach(idx -> {
NamedEntity ne = annotations.get(idx);
ne.setValue(String.valueOf(idx + 1));
ne.addToIndexes();
});
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testSingleStackedNonTokenRelationWithoutFeatureValue.
@Test
public void testSingleStackedNonTokenRelationWithoutFeatureValue() throws Exception {
JCas jcas = makeJCasOneSentence();
CAS cas = jcas.getCas();
List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
Token t1 = tokens.get(0);
Token t2 = tokens.get(tokens.size() - 1);
NamedEntity gov = new NamedEntity(jcas, t1.getBegin(), t1.getEnd());
gov.addToIndexes();
new NamedEntity(jcas, t1.getBegin(), t1.getEnd()).addToIndexes();
NamedEntity dep = new NamedEntity(jcas, t2.getBegin(), t2.getEnd());
dep.addToIndexes();
new NamedEntity(jcas, t2.getBegin(), t2.getEnd()).addToIndexes();
Type relationType = cas.getTypeSystem().getType("webanno.custom.Relation");
// One at the beginning
// WebAnno legacy conventions
// AnnotationFS fs1 = cas.createAnnotation(relationType,
// min(dep.getBegin(), gov.getBegin()),
// max(dep.getEnd(), gov.getEnd()));
// DKPro Core conventions
AnnotationFS fs1 = cas.createAnnotation(relationType, dep.getBegin(), dep.getEnd());
FSUtil.setFeature(fs1, "Governor", gov);
FSUtil.setFeature(fs1, "Dependent", dep);
cas.addFsToIndexes(fs1);
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class), WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList("webanno.custom.Relation"));
}
use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testTokenBoundedSpanWithAsteriskFeatureValue.
@Test
public void testTokenBoundedSpanWithAsteriskFeatureValue() throws Exception {
JCas jcas = makeJCasOneSentence();
for (Token t : select(jcas, Token.class)) {
NamedEntity ne = new NamedEntity(jcas, t.getBegin(), t.getEnd());
ne.setValue("*");
ne.addToIndexes();
}
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Aggregations