@Test void testCreateShouldQueryRule() { String multiOntologyTermIri = "http: OntologyTerm ontologyTerm_1 = OntologyTerm.create("http: OntologyTerm ontologyTerm_2 = OntologyTerm.create( "http: "molgenis label 2 in the genetics", singletonList("label 2")); when(ontologyService.getOntologyTerm(ontologyTerm_1.getIRI())).thenReturn(ontologyTerm_1); when(ontologyService.getOntologyTerm(ontologyTerm_2.getIRI())).thenReturn(ontologyTerm_2); QueryRule actualShouldQueryRule = semanticSearchServiceHelper.createShouldQueryRule(multiOntologyTermIri); String expectedShouldQueryRuleToString = "SHOULD (DIS_MAX ('label' FUZZY_MATCH 'gcc molgenis label', 'description' FUZZY_MATCH 'gcc molgenis label'), DIS_MAX ('label' FUZZY_MATCH '2 label', 'description' FUZZY_MATCH '2 label', 'label' FUZZY_MATCH '2 genetics molgenis label', 'description' FUZZY_MATCH '2 genetics molgenis label'))"; assertEquals(expectedShouldQueryRuleToString, actualShouldQueryRule.toString()); assertEquals(SHOULD, actualShouldQueryRule.getOperator()); }
public QueryRule createShouldQueryRule(String multiOntologyTermIri) { QueryRule shouldQueryRule = new QueryRule(new ArrayList<>()); shouldQueryRule.setOperator(Operator.SHOULD); for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) { OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri); List<String> queryTerms = parseOntologyTermQueries(ontologyTerm); Double termFrequency = getBestInverseDocumentFrequency(queryTerms); shouldQueryRule .getNestedRules() .add(createBoostedDisMaxQueryRuleForTerms(queryTerms, termFrequency)); } return shouldQueryRule; }
SemanticSearchServiceHelper { public QueryRule createShouldQueryRule(String multiOntologyTermIri) { QueryRule shouldQueryRule = new QueryRule(new ArrayList<>()); shouldQueryRule.setOperator(Operator.SHOULD); for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) { OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri); List<String> queryTerms = parseOntologyTermQueries(ontologyTerm); Double termFrequency = getBestInverseDocumentFrequency(queryTerms); shouldQueryRule .getNestedRules() .add(createBoostedDisMaxQueryRuleForTerms(queryTerms, termFrequency)); } return shouldQueryRule; } }
SemanticSearchServiceHelper { public QueryRule createShouldQueryRule(String multiOntologyTermIri) { QueryRule shouldQueryRule = new QueryRule(new ArrayList<>()); shouldQueryRule.setOperator(Operator.SHOULD); for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) { OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri); List<String> queryTerms = parseOntologyTermQueries(ontologyTerm); Double termFrequency = getBestInverseDocumentFrequency(queryTerms); shouldQueryRule .getNestedRules() .add(createBoostedDisMaxQueryRuleForTerms(queryTerms, termFrequency)); } return shouldQueryRule; } SemanticSearchServiceHelper(
      DataService dataService,
      OntologyService ontologyService,
      TermFrequencyService termFrequencyService); }
SemanticSearchServiceHelper { public QueryRule createShouldQueryRule(String multiOntologyTermIri) { QueryRule shouldQueryRule = new QueryRule(new ArrayList<>()); shouldQueryRule.setOperator(Operator.SHOULD); for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) { OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri); List<String> queryTerms = parseOntologyTermQueries(ontologyTerm); Double termFrequency = getBestInverseDocumentFrequency(queryTerms); shouldQueryRule .getNestedRules() .add(createBoostedDisMaxQueryRuleForTerms(queryTerms, termFrequency)); } return shouldQueryRule; } SemanticSearchServiceHelper(
      DataService dataService,
      OntologyService ontologyService,
      TermFrequencyService termFrequencyService); QueryRule createDisMaxQueryRuleForAttribute(
      Set<String> searchTerms, Collection<OntologyTerm> ontologyTerms); QueryRule createDisMaxQueryRuleForTerms(List<String> queryTerms); QueryRule createBoostedDisMaxQueryRuleForTerms(
      List<String> queryTerms, Double boostValue); QueryRule createShouldQueryRule(String multiOntologyTermIri); List<String> parseOntologyTermQueries(OntologyTerm ontologyTerm); Set<String> getOtLabelAndSynonyms(OntologyTerm ontologyTerm); Map<String, String> collectExpandedQueryMap(
      Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms); void collectOntologyTermQueryMap(
      Map<String, String> expanedQueryMap, OntologyTerm ontologyTerm); List<String> getAttributeIdentifiers(EntityType sourceEntityType); List<OntologyTerm> findTags(String description, List<String> ontologyIds); String processQueryString(String queryString); String parseBoostQueryString(String queryString, double boost); String escapeCharsExcludingCaretChar(String string); Set<String> removeStopWords(String description); }
SemanticSearchServiceHelper { public QueryRule createShouldQueryRule(String multiOntologyTermIri) { QueryRule shouldQueryRule = new QueryRule(new ArrayList<>()); shouldQueryRule.setOperator(Operator.SHOULD); for (String ontologyTermIri : multiOntologyTermIri.split(COMMA_CHAR)) { OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri); List<String> queryTerms = parseOntologyTermQueries(ontologyTerm); Double termFrequency = getBestInverseDocumentFrequency(queryTerms); shouldQueryRule .getNestedRules() .add(createBoostedDisMaxQueryRuleForTerms(queryTerms, termFrequency)); } return shouldQueryRule; } SemanticSearchServiceHelper(
      DataService dataService,
      OntologyService ontologyService,
      TermFrequencyService termFrequencyService); QueryRule createDisMaxQueryRuleForAttribute(
      Set<String> searchTerms, Collection<OntologyTerm> ontologyTerms); QueryRule createDisMaxQueryRuleForTerms(List<String> queryTerms); QueryRule createBoostedDisMaxQueryRuleForTerms(
      List<String> queryTerms, Double boostValue); QueryRule createShouldQueryRule(String multiOntologyTermIri); List<String> parseOntologyTermQueries(OntologyTerm ontologyTerm); Set<String> getOtLabelAndSynonyms(OntologyTerm ontologyTerm); Map<String, String> collectExpandedQueryMap(
      Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms); void collectOntologyTermQueryMap(
      Map<String, String> expanedQueryMap, OntologyTerm ontologyTerm); List<String> getAttributeIdentifiers(EntityType sourceEntityType); List<OntologyTerm> findTags(String description, List<String> ontologyIds); String processQueryString(String queryString); String parseBoostQueryString(String queryString, double boost); String escapeCharsExcludingCaretChar(String string); Set<String> removeStopWords(String description); static final int MAX_NUM_TAGS; }