TermAnnotations { public static Map<TermId, Collection<TermId>> constructTermLabelToAnnotationsMap( 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(anno.getLabel())) { result.put(anno.getLabel(), Sets.newHashSet(termId)); } else { result.get(anno.getLabel()).add(termId); } } } 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 testConstructTermLabelToAnnotationsMap() { Map<TermId, Collection<TermId>> map = TermAnnotations.constructTermLabelToAnnotationsMap(ontology, annotations); TermId test1 = TermId.of("TEST:one"); assertTrue(map.containsKey(test1)); assertEquals(3, map.size()); }