TermAnnotations { public static Map<TermId, Collection<TermId>> constructTermAnnotationToLabelsMap( Ontology ontology, Collection<? extends TermAnnotation> annotations) { final Map<TermId, Collection<TermId>> result = new HashMap<>(); for (TermAnnotation anno : annotations) { for (TermId termId : ontology.getAncestorTermIds(anno.getTermId(), true)) { if (!result.containsKey(termId)) { result.put(termId, Sets.newHashSet(anno.getLabel())); } else { result.get(termId).add(anno.getLabel()); } } } return result; } private  TermAnnotations(); static Map<TermId, Collection<TermId>> constructTermAnnotationToLabelsMap(
      Ontology ontology, Collection<? extends TermAnnotation> annotations); static Map<TermId, Collection<TermId>> constructTermLabelToAnnotationsMap(
      Ontology ontology, Collection<? extends TermAnnotation> annotations);  }
@Test void testConstructTermAnnotationToLabelsMap() { Map<TermId, Collection<TermId>> map = TermAnnotations.constructTermAnnotationToLabelsMap(ontology, annotations); assertEquals(5, map.size()); }