@Test void testDistanceFrom() { assertEquals( semanticSearchService.distanceFrom("Hypertension", ImmutableSet.of("history", "hypertens")), .6923, 0.0001, "String distance should be equal"); assertEquals( semanticSearchService.distanceFrom( "Maternal Hypertension", ImmutableSet.of("history", "hypertens")), .5454, 0.0001, "String distance should be equal"); }
float distanceFrom(String synonym, Set<String> searchTerms) { String s1 = Stemmer.stemAndJoin(splitIntoTerms(synonym)); String s2 = Stemmer.stemAndJoin(searchTerms); float distance = (float) NGramDistanceAlgorithm.stringMatching(s1, s2) / 100; LOG.debug("Similarity between: {} and {} is {}", s1, s2, distance); return distance; }
SemanticSearchServiceImpl implements SemanticSearchService { float distanceFrom(String synonym, Set<String> searchTerms) { String s1 = Stemmer.stemAndJoin(splitIntoTerms(synonym)); String s2 = Stemmer.stemAndJoin(searchTerms); float distance = (float) NGramDistanceAlgorithm.stringMatching(s1, s2) / 100; LOG.debug("Similarity between: {} and {} is {}", s1, s2, distance); return distance; } }
SemanticSearchServiceImpl implements SemanticSearchService { float distanceFrom(String synonym, Set<String> searchTerms) { String s1 = Stemmer.stemAndJoin(splitIntoTerms(synonym)); String s2 = Stemmer.stemAndJoin(searchTerms); float distance = (float) NGramDistanceAlgorithm.stringMatching(s1, s2) / 100; LOG.debug("Similarity between: {} and {} is {}", s1, s2, distance); return distance; } SemanticSearchServiceImpl(
      DataService dataService,
      OntologyService ontologyService,
      SemanticSearchServiceHelper semanticSearchServiceHelper,
      ElasticSearchExplainService elasticSearchExplainService,
      OntologyTagService ontologyTagService); }
SemanticSearchServiceImpl implements SemanticSearchService { float distanceFrom(String synonym, Set<String> searchTerms) { String s1 = Stemmer.stemAndJoin(splitIntoTerms(synonym)); String s2 = Stemmer.stemAndJoin(searchTerms); float distance = (float) NGramDistanceAlgorithm.stringMatching(s1, s2) / 100; LOG.debug("Similarity between: {} and {} is {}", s1, s2, distance); return distance; } SemanticSearchServiceImpl(
      DataService dataService,
      OntologyService ontologyService,
      SemanticSearchServiceHelper semanticSearchServiceHelper,
      ElasticSearchExplainService elasticSearchExplainService,
      OntologyTagService ontologyTagService); Hits<ExplainedAttribute> findAttributes(
      EntityType sourceEntityType, Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms); @Override EntityTypeSearchResults findAttributes(
      EntityType sourceEntityType, EntityType targetEntityType, Set<String> searchTerms); @Override AttributeSearchResults findAttributes(
      EntityType sourceEntityType,
      EntityType targetEntityType,
      Attribute targetAttribute,
      Set<String> searchTerms); Set<String> createLexicalSearchQueryTerms(
      Attribute targetAttribute, Set<String> searchTerms); Set<ExplainedQueryString> convertAttributeToExplainedAttribute(
      Attribute attribute, Map<String, String> collectExpandedQueryMap, Query<Entity> query); @Override Hits<OntologyTerm> findOntologyTerms(
      Attribute attribute, Collection<Ontology> ontologies); }
SemanticSearchServiceImpl implements SemanticSearchService { float distanceFrom(String synonym, Set<String> searchTerms) { String s1 = Stemmer.stemAndJoin(splitIntoTerms(synonym)); String s2 = Stemmer.stemAndJoin(searchTerms); float distance = (float) NGramDistanceAlgorithm.stringMatching(s1, s2) / 100; LOG.debug("Similarity between: {} and {} is {}", s1, s2, distance); return distance; } SemanticSearchServiceImpl(
      DataService dataService,
      OntologyService ontologyService,
      SemanticSearchServiceHelper semanticSearchServiceHelper,
      ElasticSearchExplainService elasticSearchExplainService,
      OntologyTagService ontologyTagService); Hits<ExplainedAttribute> findAttributes(
      EntityType sourceEntityType, Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms); @Override EntityTypeSearchResults findAttributes(
      EntityType sourceEntityType, EntityType targetEntityType, Set<String> searchTerms); @Override AttributeSearchResults findAttributes(
      EntityType sourceEntityType,
      EntityType targetEntityType,
      Attribute targetAttribute,
      Set<String> searchTerms); Set<String> createLexicalSearchQueryTerms(
      Attribute targetAttribute, Set<String> searchTerms); Set<ExplainedQueryString> convertAttributeToExplainedAttribute(
      Attribute attribute, Map<String, String> collectExpandedQueryMap, Query<Entity> query); @Override Hits<OntologyTerm> findOntologyTerms(
      Attribute attribute, Collection<Ontology> ontologies);  }