public void collectOntologyTermQueryMap( Map<String, String> expanedQueryMap, OntologyTerm ontologyTerm) { if (ontologyTerm != null) { getOtLabelAndSynonyms(ontologyTerm) .forEach( term -> expanedQueryMap.put(stemmer.cleanStemPhrase(term), ontologyTerm.getLabel())); for (OntologyTerm childOntologyTerm : ontologyService.getChildren(ontologyTerm)) { getOtLabelAndSynonyms(childOntologyTerm) .forEach( term -> expanedQueryMap.put(stemmer.cleanStemPhrase(term), ontologyTerm.getLabel())); } } }
public Map<String, String> collectExpandedQueryMap( Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms) { Map<String, String> expandedQueryMap = new LinkedHashMap<String, String>(); queryTerms .stream() .filter(StringUtils::isNotBlank) .forEach(queryTerm -> expandedQueryMap.put(stemmer.cleanStemPhrase(queryTerm), queryTerm)); for (OntologyTerm ontologyTerm : ontologyTerms) { if (!ontologyTerm.getIRI().contains(",")) { collectOntologyTermQueryMap(expandedQueryMap, ontologyTerm); } else { for (String ontologyTermIri : ontologyTerm.getIRI().split(",")) { collectOntologyTermQueryMap( expandedQueryMap, ontologyService.getOntologyTerm(ontologyTermIri)); } } } return expandedQueryMap; }