Search in sources :

Example 31 with NamedEntity

use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.

the class WebAnnoTsv3WriterTestBase method testSentenceWithLineBreak.

@Test
public void testSentenceWithLineBreak() throws Exception {
    JCas jcas = makeJCasOneSentence("This is\na test .");
    NamedEntity neToken = new NamedEntity(jcas, 0, 4);
    neToken.addToIndexes();
    writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Also used : NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) JCas(org.apache.uima.jcas.JCas) Test(org.junit.Test)

Example 32 with NamedEntity

use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.

the class WebAnnoTsv3WriterTestBase method testTokenBoundedSpanWithNastyFeatureValue.

@Test
public void testTokenBoundedSpanWithNastyFeatureValue() throws Exception {
    JCas jcas = makeJCasOneSentence();
    for (Token t : select(jcas, Token.class)) {
        NamedEntity ne = new NamedEntity(jcas, t.getBegin(), t.getEnd());
        ne.setValue("de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity:value");
        ne.addToIndexes();
    }
    writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Also used : NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) JCas(org.apache.uima.jcas.JCas) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Test(org.junit.Test)

Example 33 with NamedEntity

use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.

the class WebAnnoTsv3WriterTestBase method testTokenBoundedSpanWithFeatureValue.

@Test
public void testTokenBoundedSpanWithFeatureValue() throws Exception {
    JCas jcas = makeJCasOneSentence();
    int n = 0;
    for (Token t : select(jcas, Token.class)) {
        NamedEntity ne = new NamedEntity(jcas, t.getBegin(), t.getEnd());
        ne.setValue("NE " + n);
        ne.addToIndexes();
        n++;
    }
    writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Also used : NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) JCas(org.apache.uima.jcas.JCas) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Test(org.junit.Test)

Example 34 with NamedEntity

use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.

the class WebAnnoTsv3WriterTestBase method testSubMultiTokenSpanWithoutFeatureValue2.

@Test
public void testSubMultiTokenSpanWithoutFeatureValue2() throws Exception {
    JCas jcas = makeJCasOneSentence();
    NamedEntity ne1 = new NamedEntity(jcas, 1, 6);
    ne1.addToIndexes();
    writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class));
}
Also used : NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) JCas(org.apache.uima.jcas.JCas) Test(org.junit.Test)

Example 35 with NamedEntity

use of de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity in project webanno by webanno.

the class WebAnnoTsv3WriterTestBase method testStackedNonMultiTokenRelationWithMultipleFeatureValues.

@Test
public void testStackedNonMultiTokenRelationWithMultipleFeatureValues() 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(1);
    Token t3 = tokens.get(2);
    Token t4 = tokens.get(3);
    NamedEntity gov = new NamedEntity(jcas, t1.getBegin(), t2.getEnd());
    gov.addToIndexes();
    NamedEntity dep = new NamedEntity(jcas, t3.getBegin(), t4.getEnd());
    dep.addToIndexes();
    Type relationType = cas.getTypeSystem().getType("webanno.custom.ComplexRelation");
    // 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);
    FSUtil.setFeature(fs1, "value", "nsubj");
    FSUtil.setFeature(fs1, "boolValue", true);
    FSUtil.setFeature(fs1, "intValue", 42);
    cas.addFsToIndexes(fs1);
    // WebAnno legacy conventions
    // AnnotationFS fs2 = cas.createAnnotation(relationType,
    // min(dep.getBegin(), gov.getBegin()),
    // max(dep.getEnd(), gov.getEnd()));
    // DKPro Core conventions
    AnnotationFS fs2 = cas.createAnnotation(relationType, dep.getBegin(), dep.getEnd());
    FSUtil.setFeature(fs2, "Governor", gov);
    FSUtil.setFeature(fs2, "Dependent", dep);
    FSUtil.setFeature(fs2, "value", "obj");
    FSUtil.setFeature(fs2, "boolValue", false);
    FSUtil.setFeature(fs2, "intValue", 43);
    cas.addFsToIndexes(fs2);
    writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class), WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList("webanno.custom.ComplexRelation"));
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) Type(org.apache.uima.cas.Type) CAS(org.apache.uima.cas.CAS) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Test(org.junit.Test)

Aggregations

NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)44 Test (org.junit.Test)40 JCas (org.apache.uima.jcas.JCas)39 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)23 ArrayList (java.util.ArrayList)15 Type (org.apache.uima.cas.Type)13 CAS (org.apache.uima.cas.CAS)12 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)12 LinkedHashMap (java.util.LinkedHashMap)2 Evaluator (de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.Evaluator)1 PossibleValue (de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.PossibleValue)1 ValuesGenerator (de.tudarmstadt.ukp.clarin.webanno.constraints.evaluator.ValuesGenerator)1 ConstraintsGrammar (de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.ConstraintsGrammar)1 Parse (de.tudarmstadt.ukp.clarin.webanno.constraints.grammar.syntaxtree.Parse)1 ParsedConstraints (de.tudarmstadt.ukp.clarin.webanno.constraints.model.ParsedConstraints)1 ParserVisitor (de.tudarmstadt.ukp.clarin.webanno.constraints.visitor.ParserVisitor)1 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)1 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)1 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)1 FeatureType (de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.FeatureType)1