@Test public void testAnnotateSample() { Document doc1 = DocumentFactory.fromText(textEN); Document doc2 = DocumentFactory.fromText(textDE); List<Sentence> sents = Lists.newArrayList(doc1.getSentence(0), doc1.getSentence(1), doc2.getSentence(0), doc2.getSentence(1)); Snippet snippet = new Snippet(sents, false); Assert.assertEquals(0, doc1.countAnnotations()); Assert.assertEquals(0, doc2.countAnnotations()); Assert.assertEquals(4, snippet.countSentences()); Assert.assertEquals(0, snippet.countAnnotations()); ann.annotate(snippet); doc1.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { }); doc2.streamAnnotations(Annotation.Source.PRED, MentionAnnotation.class).forEach(ann -> { }); Assert.assertEquals(0, snippet.countAnnotations()); Assert.assertEquals(9, doc1.countAnnotations()); Assert.assertEquals(14, doc2.countAnnotations()); }
@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);  }