@Test public void testProcess() throws Exception { JCas jcas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-morpho-syntax-types", "de.julielab.jcore.types.jcore-document-meta-types", "de.julielab.jcore.types.jcore-semantics-biology-types"); jcas.setDocumentText( "Ten out-patients with pustulosis palmaris et plantaris were examined with direct immunofluorescence (IF) technique for deposition of fibrinogen, fibrin or its degradation products (FR-antigen) in affected and unaffected skin, together with heparin-precipitable fraction (HPF), cryoglobulin and total plasma fibrinogen in the blood."); new Sentence(jcas, 0, jcas.getDocumentText().length()).addToIndexes(); AnalysisEngine bannerAe = AnalysisEngineFactory.createEngine(BANNERAnnotator.class, BANNERAnnotator.PARAM_CONFIG_FILE, "src/test/resources/banner_ae_test.xml", BANNERAnnotator.PARAM_TYPE_MAPPING, new String[] {"GENE=de.julielab.jcore.types.Gene"}); bannerAe.process(jcas); List<Gene> geneList = new ArrayList<Gene>(JCasUtil.select(jcas, Gene.class)); assertEquals("fibrinogen", geneList.get(0).getCoveredText()); assertEquals("fibrin", geneList.get(1).getCoveredText()); assertEquals("FR-antigen", geneList.get(2).getCoveredText()); assertEquals("cryoglobulin", geneList.get(3).getCoveredText()); assertEquals("fibrinogen", geneList.get(4).getCoveredText()); }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { if (tagger == null) { try { tagger = CRFTagger.load(modelIs, lemmatiser, posTagger, dictionary); } catch (IOException e) { log.error("Could not load the BANNER model at {}", modelFilename, e); throw new AnalysisEngineProcessException(e); } } String docId = "<unknown>"; try { docId = JCoReTools.getDocId(jcas); FSIterator<Annotation> sentIt = jcas.getAnnotationIndex(de.julielab.jcore.types.Sentence.type).iterator(); int geneCount = 0; int sentCount = 0; while (sentIt.hasNext()) { de.julielab.jcore.types.Sentence jcoreSentence = (de.julielab.jcore.types.Sentence) sentIt.next(); int sentenceBegin = jcoreSentence.getBegin(); String sentenceId = jcoreSentence.getId() != null ? jcoreSentence.getId() : docId + ": " + sentCount++; Sentence sentence = new Sentence(sentenceId, docId, jcoreSentence.getCoveredText()); try { sentence = BANNER.process(tagger, tokenizer, postProcessor, sentence); } catch (Exception e) { log.error("Exception while running BANNER on sentence {}", jcoreSentence.getCoveredText(), e); throw e; } for (Mention mention : sentence.getMentions()) { EntityType entityType = mention.getEntityType(); String typeName = typeMap.getOrDefault(entityType.getText(), EntityMention.class.getCanonicalName()); Annotation a = JCoReAnnotationTools.getAnnotationByClassName(jcas, typeName); a.setBegin(sentenceBegin + mention.getStartChar()); a.setEnd(sentenceBegin + mention.getEndChar()); if (a instanceof de.julielab.jcore.types.Annotation) { de.julielab.jcore.types.Annotation jcoreA = (de.julielab.jcore.types.Annotation) a; jcoreA.setId("BANNER, " + docId + ": " + geneCount++); jcoreA.setComponentId(BANNERAnnotator.class.getCanonicalName()); jcoreA.setConfidence(String.valueOf(mention.getProbability())); } if (a instanceof EntityMention) { EntityMention e = (EntityMention) a; e.setSpecificType(entityType.getText()); } a.addToIndexes(); } } } catch (Exception e) { log.error("Exception occurred while running the BANNER annotator on document {}.", docId, e); throw new AnalysisEngineProcessException(e); } }
BANNERAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { if (tagger == null) { try { tagger = CRFTagger.load(modelIs, lemmatiser, posTagger, dictionary); } catch (IOException e) { log.error("Could not load the BANNER model at {}", modelFilename, e); throw new AnalysisEngineProcessException(e); } } String docId = "<unknown>"; try { docId = JCoReTools.getDocId(jcas); FSIterator<Annotation> sentIt = jcas.getAnnotationIndex(de.julielab.jcore.types.Sentence.type).iterator(); int geneCount = 0; int sentCount = 0; while (sentIt.hasNext()) { de.julielab.jcore.types.Sentence jcoreSentence = (de.julielab.jcore.types.Sentence) sentIt.next(); int sentenceBegin = jcoreSentence.getBegin(); String sentenceId = jcoreSentence.getId() != null ? jcoreSentence.getId() : docId + ": " + sentCount++; Sentence sentence = new Sentence(sentenceId, docId, jcoreSentence.getCoveredText()); try { sentence = BANNER.process(tagger, tokenizer, postProcessor, sentence); } catch (Exception e) { log.error("Exception while running BANNER on sentence {}", jcoreSentence.getCoveredText(), e); throw e; } for (Mention mention : sentence.getMentions()) { EntityType entityType = mention.getEntityType(); String typeName = typeMap.getOrDefault(entityType.getText(), EntityMention.class.getCanonicalName()); Annotation a = JCoReAnnotationTools.getAnnotationByClassName(jcas, typeName); a.setBegin(sentenceBegin + mention.getStartChar()); a.setEnd(sentenceBegin + mention.getEndChar()); if (a instanceof de.julielab.jcore.types.Annotation) { de.julielab.jcore.types.Annotation jcoreA = (de.julielab.jcore.types.Annotation) a; jcoreA.setId("BANNER, " + docId + ": " + geneCount++); jcoreA.setComponentId(BANNERAnnotator.class.getCanonicalName()); jcoreA.setConfidence(String.valueOf(mention.getProbability())); } if (a instanceof EntityMention) { EntityMention e = (EntityMention) a; e.setSpecificType(entityType.getText()); } a.addToIndexes(); } } } catch (Exception e) { log.error("Exception occurred while running the BANNER annotator on document {}.", docId, e); throw new AnalysisEngineProcessException(e); } } }
BANNERAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { if (tagger == null) { try { tagger = CRFTagger.load(modelIs, lemmatiser, posTagger, dictionary); } catch (IOException e) { log.error("Could not load the BANNER model at {}", modelFilename, e); throw new AnalysisEngineProcessException(e); } } String docId = "<unknown>"; try { docId = JCoReTools.getDocId(jcas); FSIterator<Annotation> sentIt = jcas.getAnnotationIndex(de.julielab.jcore.types.Sentence.type).iterator(); int geneCount = 0; int sentCount = 0; while (sentIt.hasNext()) { de.julielab.jcore.types.Sentence jcoreSentence = (de.julielab.jcore.types.Sentence) sentIt.next(); int sentenceBegin = jcoreSentence.getBegin(); String sentenceId = jcoreSentence.getId() != null ? jcoreSentence.getId() : docId + ": " + sentCount++; Sentence sentence = new Sentence(sentenceId, docId, jcoreSentence.getCoveredText()); try { sentence = BANNER.process(tagger, tokenizer, postProcessor, sentence); } catch (Exception e) { log.error("Exception while running BANNER on sentence {}", jcoreSentence.getCoveredText(), e); throw e; } for (Mention mention : sentence.getMentions()) { EntityType entityType = mention.getEntityType(); String typeName = typeMap.getOrDefault(entityType.getText(), EntityMention.class.getCanonicalName()); Annotation a = JCoReAnnotationTools.getAnnotationByClassName(jcas, typeName); a.setBegin(sentenceBegin + mention.getStartChar()); a.setEnd(sentenceBegin + mention.getEndChar()); if (a instanceof de.julielab.jcore.types.Annotation) { de.julielab.jcore.types.Annotation jcoreA = (de.julielab.jcore.types.Annotation) a; jcoreA.setId("BANNER, " + docId + ": " + geneCount++); jcoreA.setComponentId(BANNERAnnotator.class.getCanonicalName()); jcoreA.setConfidence(String.valueOf(mention.getProbability())); } if (a instanceof EntityMention) { EntityMention e = (EntityMention) a; e.setSpecificType(entityType.getText()); } a.addToIndexes(); } } } catch (Exception e) { log.error("Exception occurred while running the BANNER annotator on document {}.", docId, e); throw new AnalysisEngineProcessException(e); } }  }
BANNERAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { if (tagger == null) { try { tagger = CRFTagger.load(modelIs, lemmatiser, posTagger, dictionary); } catch (IOException e) { log.error("Could not load the BANNER model at {}", modelFilename, e); throw new AnalysisEngineProcessException(e); } } String docId = "<unknown>"; try { docId = JCoReTools.getDocId(jcas); FSIterator<Annotation> sentIt = jcas.getAnnotationIndex(de.julielab.jcore.types.Sentence.type).iterator(); int geneCount = 0; int sentCount = 0; while (sentIt.hasNext()) { de.julielab.jcore.types.Sentence jcoreSentence = (de.julielab.jcore.types.Sentence) sentIt.next(); int sentenceBegin = jcoreSentence.getBegin(); String sentenceId = jcoreSentence.getId() != null ? jcoreSentence.getId() : docId + ": " + sentCount++; Sentence sentence = new Sentence(sentenceId, docId, jcoreSentence.getCoveredText()); try { sentence = BANNER.process(tagger, tokenizer, postProcessor, sentence); } catch (Exception e) { log.error("Exception while running BANNER on sentence {}", jcoreSentence.getCoveredText(), e); throw e; } for (Mention mention : sentence.getMentions()) { EntityType entityType = mention.getEntityType(); String typeName = typeMap.getOrDefault(entityType.getText(), EntityMention.class.getCanonicalName()); Annotation a = JCoReAnnotationTools.getAnnotationByClassName(jcas, typeName); a.setBegin(sentenceBegin + mention.getStartChar()); a.setEnd(sentenceBegin + mention.getEndChar()); if (a instanceof de.julielab.jcore.types.Annotation) { de.julielab.jcore.types.Annotation jcoreA = (de.julielab.jcore.types.Annotation) a; jcoreA.setId("BANNER, " + docId + ": " + geneCount++); jcoreA.setComponentId(BANNERAnnotator.class.getCanonicalName()); jcoreA.setConfidence(String.valueOf(mention.getProbability())); } if (a instanceof EntityMention) { EntityMention e = (EntityMention) a; e.setSpecificType(entityType.getText()); } a.addToIndexes(); } } } catch (Exception e) { log.error("Exception occurred while running the BANNER annotator on document {}.", docId, e); throw new AnalysisEngineProcessException(e); } }  @Override void initialize(UimaContext aContext); @Override void process(JCas jcas); }
BANNERAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { if (tagger == null) { try { tagger = CRFTagger.load(modelIs, lemmatiser, posTagger, dictionary); } catch (IOException e) { log.error("Could not load the BANNER model at {}", modelFilename, e); throw new AnalysisEngineProcessException(e); } } String docId = "<unknown>"; try { docId = JCoReTools.getDocId(jcas); FSIterator<Annotation> sentIt = jcas.getAnnotationIndex(de.julielab.jcore.types.Sentence.type).iterator(); int geneCount = 0; int sentCount = 0; while (sentIt.hasNext()) { de.julielab.jcore.types.Sentence jcoreSentence = (de.julielab.jcore.types.Sentence) sentIt.next(); int sentenceBegin = jcoreSentence.getBegin(); String sentenceId = jcoreSentence.getId() != null ? jcoreSentence.getId() : docId + ": " + sentCount++; Sentence sentence = new Sentence(sentenceId, docId, jcoreSentence.getCoveredText()); try { sentence = BANNER.process(tagger, tokenizer, postProcessor, sentence); } catch (Exception e) { log.error("Exception while running BANNER on sentence {}", jcoreSentence.getCoveredText(), e); throw e; } for (Mention mention : sentence.getMentions()) { EntityType entityType = mention.getEntityType(); String typeName = typeMap.getOrDefault(entityType.getText(), EntityMention.class.getCanonicalName()); Annotation a = JCoReAnnotationTools.getAnnotationByClassName(jcas, typeName); a.setBegin(sentenceBegin + mention.getStartChar()); a.setEnd(sentenceBegin + mention.getEndChar()); if (a instanceof de.julielab.jcore.types.Annotation) { de.julielab.jcore.types.Annotation jcoreA = (de.julielab.jcore.types.Annotation) a; jcoreA.setId("BANNER, " + docId + ": " + geneCount++); jcoreA.setComponentId(BANNERAnnotator.class.getCanonicalName()); jcoreA.setConfidence(String.valueOf(mention.getProbability())); } if (a instanceof EntityMention) { EntityMention e = (EntityMention) a; e.setSpecificType(entityType.getText()); } a.addToIndexes(); } } } catch (Exception e) { log.error("Exception occurred while running the BANNER annotator on document {}.", docId, e); throw new AnalysisEngineProcessException(e); } }  @Override void initialize(UimaContext aContext); @Override void process(JCas jcas); static final String PARAM_CONFIG_FILE; static final String PARAM_TYPE_MAPPING; }