@Test public void testDocumentClasses() throws Exception { final JCas jCas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-morpho-syntax-types", "de.julielab.jcore.types.jcore-document-meta-types"); final ExternalResourceDescription externalResourceDescription = ExternalResourceFactory.createExternalResourceDescription(InMemoryFileDocumentClassAnnotationProvider.class, new File("src/test/resources/documentClasses.tsv")); final AnalysisEngine engine = AnalysisEngineFactory.createEngine(AnnotationAdderAnnotator.class, AnnotationAdderAnnotator.KEY_ANNOTATION_SOURCE, externalResourceDescription); jCas.setDocumentText("BRCA PRKII are the genes of this sentence."); final Header h = new Header(jCas); h.setDocId("doc1"); h.addToIndexes(); engine.process(jCas); final AutoDescriptor ad = JCasUtil.selectSingle(jCas, AutoDescriptor.class); assertThat(ad.getDocumentClasses().size()).isEqualTo(2); final DocumentClass dc1 = (DocumentClass) ad.getDocumentClasses().get(0); final DocumentClass dc2 = (DocumentClass) ad.getDocumentClasses().get(1); assertThat(dc1.getClassname()).isEqualTo("PM"); assertThat(dc1.getConfidence()).isCloseTo(0.97989035, Offset.offset(.000000001)); assertThat(dc1.getComponentId()).isEqualTo("2017 GRU"); assertThat(dc2.getClassname()).isEqualTo("Not PM"); assertThat(dc2.getConfidence()).isCloseTo(0.9543127, Offset.offset(.000000001)); assertThat(dc2.getComponentId()).isEqualTo("2018 GRU"); }
@Override public void process(final JCas aJCas) { final String docId = JCoReTools.getDocId(aJCas); if (docId == null) log.error("The current document does not have a header. Cannot add external annotations."); final AnnotationData annotations = annotationProvider.getAnnotations(docId); final AnnotationAdderHelper helper = new AnnotationAdderHelper(); if (annotations != null) { boolean success = false; int adderNum = 0; while (adderNum < annotationAdders.size() && !(success = annotationAdders.get(adderNum).addAnnotations(annotations, helper, adderConfiguration, aJCas, preventProcessedOnDigestMismatch))) { ++adderNum; } if (!success) throw new IllegalArgumentException("There was no annotation adder to handle the annotation data of class " + annotations.getClass().getCanonicalName()); } else { log.debug("No external annotations were delivered for document ID {}", docId); } }
AnnotationAdderAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas aJCas) { final String docId = JCoReTools.getDocId(aJCas); if (docId == null) log.error("The current document does not have a header. Cannot add external annotations."); final AnnotationData annotations = annotationProvider.getAnnotations(docId); final AnnotationAdderHelper helper = new AnnotationAdderHelper(); if (annotations != null) { boolean success = false; int adderNum = 0; while (adderNum < annotationAdders.size() && !(success = annotationAdders.get(adderNum).addAnnotations(annotations, helper, adderConfiguration, aJCas, preventProcessedOnDigestMismatch))) { ++adderNum; } if (!success) throw new IllegalArgumentException("There was no annotation adder to handle the annotation data of class " + annotations.getClass().getCanonicalName()); } else { log.debug("No external annotations were delivered for document ID {}", docId); } } }
AnnotationAdderAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas aJCas) { final String docId = JCoReTools.getDocId(aJCas); if (docId == null) log.error("The current document does not have a header. Cannot add external annotations."); final AnnotationData annotations = annotationProvider.getAnnotations(docId); final AnnotationAdderHelper helper = new AnnotationAdderHelper(); if (annotations != null) { boolean success = false; int adderNum = 0; while (adderNum < annotationAdders.size() && !(success = annotationAdders.get(adderNum).addAnnotations(annotations, helper, adderConfiguration, aJCas, preventProcessedOnDigestMismatch))) { ++adderNum; } if (!success) throw new IllegalArgumentException("There was no annotation adder to handle the annotation data of class " + annotations.getClass().getCanonicalName()); } else { log.debug("No external annotations were delivered for document ID {}", docId); } }  }
AnnotationAdderAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas aJCas) { final String docId = JCoReTools.getDocId(aJCas); if (docId == null) log.error("The current document does not have a header. Cannot add external annotations."); final AnnotationData annotations = annotationProvider.getAnnotations(docId); final AnnotationAdderHelper helper = new AnnotationAdderHelper(); if (annotations != null) { boolean success = false; int adderNum = 0; while (adderNum < annotationAdders.size() && !(success = annotationAdders.get(adderNum).addAnnotations(annotations, helper, adderConfiguration, aJCas, preventProcessedOnDigestMismatch))) { ++adderNum; } if (!success) throw new IllegalArgumentException("There was no annotation adder to handle the annotation data of class " + annotations.getClass().getCanonicalName()); } else { log.debug("No external annotations were delivered for document ID {}", docId); } }  @Override void initialize(final UimaContext aContext); @Override void process(final JCas aJCas); }
AnnotationAdderAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas aJCas) { final String docId = JCoReTools.getDocId(aJCas); if (docId == null) log.error("The current document does not have a header. Cannot add external annotations."); final AnnotationData annotations = annotationProvider.getAnnotations(docId); final AnnotationAdderHelper helper = new AnnotationAdderHelper(); if (annotations != null) { boolean success = false; int adderNum = 0; while (adderNum < annotationAdders.size() && !(success = annotationAdders.get(adderNum).addAnnotations(annotations, helper, adderConfiguration, aJCas, preventProcessedOnDigestMismatch))) { ++adderNum; } if (!success) throw new IllegalArgumentException("There was no annotation adder to handle the annotation data of class " + annotations.getClass().getCanonicalName()); } else { log.debug("No external annotations were delivered for document ID {}", docId); } }  @Override void initialize(final UimaContext aContext); @Override void process(final JCas aJCas); static final String KEY_ANNOTATION_SOURCE; static final String PARAM_OFFSET_MODE; static final String PARAM_DEFAULT_UIMA_TYPE; static final String PARAM_PREVENT_PROCESSED_MARK; }