use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testTokenBoundedSpanWithUnderscoreFeatureValue.
@Test
public void testTokenBoundedSpanWithUnderscoreFeatureValue() 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));
}
use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method testSingleStackedNonTokenRelationWithoutFeatureValue3.
@Test
public void testSingleStackedNonTokenRelationWithoutFeatureValue3() 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();
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 testSingleStackedNonTokenOverlappingRelationWithoutFeatureValue.
@Test
public void testSingleStackedNonTokenOverlappingRelationWithoutFeatureValue() 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(), t2.getEnd());
gov.addToIndexes();
new NamedEntity(jcas, t1.getBegin(), t2.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 testZeroLengthSpansWithoutFeatureValues.
@Test
public void testZeroLengthSpansWithoutFeatureValues() throws Exception {
JCas jcas = makeJCasOneSentence();
// One at the beginning
new NamedEntity(jcas, 0, 0).addToIndexes();
// One at the end
new NamedEntity(jcas, jcas.getDocumentText().length(), jcas.getDocumentText().length()).addToIndexes();
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Aggregations