@Test public void testAnnotate() { Document doc = ann.annotate(textETC); System.out.println(String.format("Document [%s]: \"%s\"", doc.getLanguage(), doc.getText())); doc.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { System.out.println(String.format("-- %s [%s]\t%s", ann.getText(), ann.getType(), ann.getConfidence())); Assert.assertEquals(textETC.substring(ann.getBegin(), ann.getEnd()), ann.getText()); }); doc = ann.annotate(textEN); System.out.println(String.format("Document [%s]: \"%s\"", doc.getLanguage(), doc.getText())); doc.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { System.out.println(String.format("-- %s [%s]\t%s", ann.getText(), ann.getType(), ann.getConfidence())); Assert.assertEquals(textEN.substring(ann.getBegin(), ann.getEnd()), ann.getText()); }); doc = ann.annotate(textDE); System.out.println(String.format("Document [%s]: \"%s\"", doc.getLanguage(), doc.getText())); doc.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { System.out.println(String.format("-- %s [%s]\t%s", ann.getText(), ann.getType(), ann.getConfidence())); Assert.assertEquals(textDE.substring(ann.getBegin(), ann.getEnd()), ann.getText()); }); doc = ann.annotate(textFR); System.out.println(String.format("Document [%s]: \"%s\"", doc.getLanguage(), doc.getText())); doc.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { System.out.println(String.format("-- %s [%s]\t%s", ann.getText(), ann.getType(), ann.getConfidence())); Assert.assertEquals(textFR.substring(ann.getBegin(), ann.getEnd()), ann.getText()); }); }
@Override public void annotate(Collection<Document> docs) { Map<String, List<Document>> groups = docs.stream().collect(Collectors.groupingBy(doc -> Optional.ofNullable(doc.getLanguage()).orElse("unk"))); for(Map.Entry<String, List<Document>> group : groups.entrySet()) { if(group.getKey().equals("de")) { annotatorDE.annotate(group.getValue()); } else if(group.getKey().equals("en")) { annotatorEN.annotate(group.getValue()); } else { log.warn("Detected language " + group.getKey() + ", using English annotator."); annotatorEN.annotate(group.getValue()); } } }
GenericMentionAnnotator extends MentionAnnotator { @Override public void annotate(Collection<Document> docs) { Map<String, List<Document>> groups = docs.stream().collect(Collectors.groupingBy(doc -> Optional.ofNullable(doc.getLanguage()).orElse("unk"))); for(Map.Entry<String, List<Document>> group : groups.entrySet()) { if(group.getKey().equals("de")) { annotatorDE.annotate(group.getValue()); } else if(group.getKey().equals("en")) { annotatorEN.annotate(group.getValue()); } else { log.warn("Detected language " + group.getKey() + ", using English annotator."); annotatorEN.annotate(group.getValue()); } } } }
GenericMentionAnnotator extends MentionAnnotator { @Override public void annotate(Collection<Document> docs) { Map<String, List<Document>> groups = docs.stream().collect(Collectors.groupingBy(doc -> Optional.ofNullable(doc.getLanguage()).orElse("unk"))); for(Map.Entry<String, List<Document>> group : groups.entrySet()) { if(group.getKey().equals("de")) { annotatorDE.annotate(group.getValue()); } else if(group.getKey().equals("en")) { annotatorEN.annotate(group.getValue()); } else { log.warn("Detected language " + group.getKey() + ", using English annotator."); annotatorEN.annotate(group.getValue()); } } } protected  GenericMentionAnnotator(); }
GenericMentionAnnotator extends MentionAnnotator { @Override public void annotate(Collection<Document> docs) { Map<String, List<Document>> groups = docs.stream().collect(Collectors.groupingBy(doc -> Optional.ofNullable(doc.getLanguage()).orElse("unk"))); for(Map.Entry<String, List<Document>> group : groups.entrySet()) { if(group.getKey().equals("de")) { annotatorDE.annotate(group.getValue()); } else if(group.getKey().equals("en")) { annotatorEN.annotate(group.getValue()); } else { log.warn("Detected language " + group.getKey() + ", using English annotator."); annotatorEN.annotate(group.getValue()); } } } protected  GenericMentionAnnotator(); static MentionAnnotator create(); MentionAnnotator getEnglishMentionAnnotator(); MentionAnnotator getGermanMentionAnnotator(); @Override void annotate(Collection<Document> docs); }
GenericMentionAnnotator extends MentionAnnotator { @Override public void annotate(Collection<Document> docs) { Map<String, List<Document>> groups = docs.stream().collect(Collectors.groupingBy(doc -> Optional.ofNullable(doc.getLanguage()).orElse("unk"))); for(Map.Entry<String, List<Document>> group : groups.entrySet()) { if(group.getKey().equals("de")) { annotatorDE.annotate(group.getValue()); } else if(group.getKey().equals("en")) { annotatorEN.annotate(group.getValue()); } else { log.warn("Detected language " + group.getKey() + ", using English annotator."); annotatorEN.annotate(group.getValue()); } } } protected  GenericMentionAnnotator(); static MentionAnnotator create(); MentionAnnotator getEnglishMentionAnnotator(); MentionAnnotator getGermanMentionAnnotator(); @Override void annotate(Collection<Document> docs);  }