Class SemanticSearchServiceHelper


  • public class SemanticSearchServiceHelper
    extends Object
    • Constructor Detail

      • SemanticSearchServiceHelper

        public SemanticSearchServiceHelper​(org.molgenis.data.DataService dataService,
                                           org.molgenis.ontology.core.service.OntologyService ontologyService,
                                           org.molgenis.ontology.core.ic.TermFrequencyService termFrequencyService)
    • Method Detail

      • createDisMaxQueryRuleForAttribute

        public org.molgenis.data.QueryRule createDisMaxQueryRuleForAttribute​(Set<String> searchTerms,
                                                                             Collection<org.molgenis.ontology.core.model.OntologyTerm> ontologyTerms)
        Create a disMaxJunc query rule based on the given search terms as well as the information from given ontology terms
        Returns:
        disMaxJunc queryRule
      • createDisMaxQueryRuleForTerms

        public org.molgenis.data.QueryRule createDisMaxQueryRuleForTerms​(List<String> queryTerms)
        Create disMaxJunc query rule based a list of queryTerm. All queryTerms are lower cased and stop words are removed
        Returns:
        disMaxJunc queryRule
      • createBoostedDisMaxQueryRuleForTerms

        public org.molgenis.data.QueryRule createBoostedDisMaxQueryRuleForTerms​(List<String> queryTerms,
                                                                                Double boostValue)
        Create a disMaxQueryRule with corresponding boosted value
        Returns:
        a disMaxQueryRule with boosted value
      • createShouldQueryRule

        public org.molgenis.data.QueryRule createShouldQueryRule​(String multiOntologyTermIri)
        Create a boolean should query for composite tags containing multiple ontology terms
        Returns:
        return a boolean should queryRule
      • parseOntologyTermQueries

        public List<String> parseOntologyTermQueries​(org.molgenis.ontology.core.model.OntologyTerm ontologyTerm)
        Create a list of string queries based on the information collected from current ontologyterm including label, synonyms and child ontologyterms
      • getOtLabelAndSynonyms

        public Set<String> getOtLabelAndSynonyms​(org.molgenis.ontology.core.model.OntologyTerm ontologyTerm)
        A helper function to collect synonyms as well as label of ontologyterm
        Returns:
        a list of synonyms plus label
      • collectExpandedQueryMap

        public Map<String,​String> collectExpandedQueryMap​(Set<String> queryTerms,
                                                                Collection<org.molgenis.ontology.core.model.OntologyTerm> ontologyTerms)
      • collectOntologyTermQueryMap

        public void collectOntologyTermQueryMap​(Map<String,​String> expanedQueryMap,
                                                org.molgenis.ontology.core.model.OntologyTerm ontologyTerm)
      • getAttributeIdentifiers

        public List<String> getAttributeIdentifiers​(org.molgenis.data.meta.model.EntityType sourceEntityType)
        A helper function that gets identifiers of all the attributes from one EntityType
      • findTags

        public List<org.molgenis.ontology.core.model.OntologyTerm> findTags​(String description,
                                                                            List<String> ontologyIds)
      • processQueryString

        public String processQueryString​(String queryString)
      • parseBoostQueryString

        public String parseBoostQueryString​(String queryString,
                                            double boost)
      • escapeCharsExcludingCaretChar

        public String escapeCharsExcludingCaretChar​(String string)
      • removeStopWords

        public Set<String> removeStopWords​(String description)