@Test public void voteMatch_ONE_ORG_NAME__ENOUGH_COMMON_WORDS() { resetOrgNames("University of Toronto"); when(organizationSectionsSplitter.splitToSections(affOrgName)).thenReturn(newArrayList("Chemistry Department", "Universiti of Toronto")); whenFilterCharsThen("University of Toronto", "University Toronto"); whenFilterCharsThen("Chemistry Department", "Chemistry Department"); whenFilterCharsThen("Universiti of Toronto", "Universiti Toronto"); when(commonSimilarWordCalculator.calcSimilarWordRatio(newArrayList("Chemistry", "Department"), newArrayList("University", "Toronto"))) .thenReturn(MIN_COMMON_WORDS_RATIO - 0.01); when(commonSimilarWordCalculator.calcSimilarWordRatio(newArrayList("Universiti", "Toronto"), newArrayList("University", "Toronto"))) .thenReturn(MIN_COMMON_WORDS_RATIO + 0.01); assertTrue(voter.voteMatch(affiliation, organization)); }
@Override public boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization) { List<String> affSections = organizationSectionsSplitter.splitToSections(affiliation.getOrganizationName()); for (String orgName : getOrgNamesFunction.apply(organization)) { String filteredOrgName = stringFilter.filterCharsAndShortWords(orgName, charsToFilter, wordToRemoveMaxLength); if (StringUtils.isEmpty(filteredOrgName)) { continue; } List<String> orgWords = ImmutableList.copyOf(StringUtils.split(filteredOrgName)); if (isAnyAffSectionInOrgWords(affSections, orgWords)) { return true; } } return false; }
CommonAffSectionWordsVoter extends AbstractAffOrgMatchVoter { @Override public boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization) { List<String> affSections = organizationSectionsSplitter.splitToSections(affiliation.getOrganizationName()); for (String orgName : getOrgNamesFunction.apply(organization)) { String filteredOrgName = stringFilter.filterCharsAndShortWords(orgName, charsToFilter, wordToRemoveMaxLength); if (StringUtils.isEmpty(filteredOrgName)) { continue; } List<String> orgWords = ImmutableList.copyOf(StringUtils.split(filteredOrgName)); if (isAnyAffSectionInOrgWords(affSections, orgWords)) { return true; } } return false; } }
CommonAffSectionWordsVoter extends AbstractAffOrgMatchVoter { @Override public boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization) { List<String> affSections = organizationSectionsSplitter.splitToSections(affiliation.getOrganizationName()); for (String orgName : getOrgNamesFunction.apply(organization)) { String filteredOrgName = stringFilter.filterCharsAndShortWords(orgName, charsToFilter, wordToRemoveMaxLength); if (StringUtils.isEmpty(filteredOrgName)) { continue; } List<String> orgWords = ImmutableList.copyOf(StringUtils.split(filteredOrgName)); if (isAnyAffSectionInOrgWords(affSections, orgWords)) { return true; } } return false; } CommonAffSectionWordsVoter(List<Character> charsToFilter, int wordToRemoveMaxLength, double minFittingOrgWordsRatio); }
CommonAffSectionWordsVoter extends AbstractAffOrgMatchVoter { @Override public boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization) { List<String> affSections = organizationSectionsSplitter.splitToSections(affiliation.getOrganizationName()); for (String orgName : getOrgNamesFunction.apply(organization)) { String filteredOrgName = stringFilter.filterCharsAndShortWords(orgName, charsToFilter, wordToRemoveMaxLength); if (StringUtils.isEmpty(filteredOrgName)) { continue; } List<String> orgWords = ImmutableList.copyOf(StringUtils.split(filteredOrgName)); if (isAnyAffSectionInOrgWords(affSections, orgWords)) { return true; } } return false; } CommonAffSectionWordsVoter(List<Character> charsToFilter, int wordToRemoveMaxLength, double minFittingOrgWordsRatio); @Override boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization); void setGetOrgNamesFunction(Function<AffMatchOrganization, List<String>> getOrgNamesFunction); void setCommonSimilarWordCalculator(CommonSimilarWordCalculator commonSimilarWordCalculator); @Override String toString(); }
CommonAffSectionWordsVoter extends AbstractAffOrgMatchVoter { @Override public boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization) { List<String> affSections = organizationSectionsSplitter.splitToSections(affiliation.getOrganizationName()); for (String orgName : getOrgNamesFunction.apply(organization)) { String filteredOrgName = stringFilter.filterCharsAndShortWords(orgName, charsToFilter, wordToRemoveMaxLength); if (StringUtils.isEmpty(filteredOrgName)) { continue; } List<String> orgWords = ImmutableList.copyOf(StringUtils.split(filteredOrgName)); if (isAnyAffSectionInOrgWords(affSections, orgWords)) { return true; } } return false; } CommonAffSectionWordsVoter(List<Character> charsToFilter, int wordToRemoveMaxLength, double minFittingOrgWordsRatio); @Override boolean voteMatch(AffMatchAffiliation affiliation, AffMatchOrganization organization); void setGetOrgNamesFunction(Function<AffMatchOrganization, List<String>> getOrgNamesFunction); void setCommonSimilarWordCalculator(CommonSimilarWordCalculator commonSimilarWordCalculator); @Override String toString();  }