Search in sources :

Example 6 with CasDoctor

use of de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor 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

CasDoctor (de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor)6 LogMessage (de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage)5 JCas (org.apache.uima.jcas.JCas)4 AnnotationDocument (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument)3 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)3 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)3 ArrayList (java.util.ArrayList)3 CAS (org.apache.uima.cas.CAS)3 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 UIMAException (org.apache.uima.UIMAException)2 Type (org.apache.uima.cas.Type)2 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)2 TypeDescription (org.apache.uima.resource.metadata.TypeDescription)2 CasStorageService (de.tudarmstadt.ukp.clarin.webanno.api.CasStorageService)1 ANNOTATION_FOLDER (de.tudarmstadt.ukp.clarin.webanno.api.ProjectService.ANNOTATION_FOLDER)1 DOCUMENT_FOLDER (de.tudarmstadt.ukp.clarin.webanno.api.ProjectService.DOCUMENT_FOLDER)1 PROJECT_FOLDER (de.tudarmstadt.ukp.clarin.webanno.api.ProjectService.PROJECT_FOLDER)1 CasDoctorException (de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctorException)1