Search in sources :

Example 16 with LogMessage

use of de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage in project webanno by webanno.

the class AllAnnotationsIndexedCheckTest method testOK.

@Test
public void testOK() throws Exception {
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory().createTypeSystemDescription();
    String refTypeName = "RefType";
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    Type refType = cas.getTypeSystem().getType(refTypeName);
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);
    // An indexed annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno2);
    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    messages.forEach(System.out::println);
    assertTrue(result);
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) CAS(org.apache.uima.cas.CAS) LogMessage(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage) ArrayList(java.util.ArrayList) CasDoctor(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) Test(org.junit.Test)

Example 17 with LogMessage

use of de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage in project webanno by webanno.

the class AllAnnotationsIndexedCheckTest method testFail.

@Test
public void testFail() throws Exception {
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory().createTypeSystemDescription();
    String refTypeName = "RefType";
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    Type refType = cas.getTypeSystem().getType(refTypeName);
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);
    // A non-index annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    messages.forEach(System.out::println);
    assertFalse(result);
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) CAS(org.apache.uima.cas.CAS) LogMessage(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage) ArrayList(java.util.ArrayList) CasDoctor(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) Test(org.junit.Test)

Aggregations

LogMessage (de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage)17 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)11 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)8 ArrayList (java.util.ArrayList)7 Type (org.apache.uima.cas.Type)7 CasDoctor (de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor)5 FeatureStructure (org.apache.uima.cas.FeatureStructure)4 CasUtil.getType (org.apache.uima.fit.util.CasUtil.getType)4 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)3 JCas (org.apache.uima.jcas.JCas)3 Test (org.junit.Test)3 AnnotationDocument (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument)2 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)2 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)2 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)2 CAS (org.apache.uima.cas.CAS)2 CASException (org.apache.uima.cas.CASException)2 TypeDescription (org.apache.uima.resource.metadata.TypeDescription)2 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)2 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)1