@Test public void calcSimilarWordRatio() { List<String> findWords = ImmutableList.of("electronics", "department", "university", "warsaw"); when(similarityChecker.containsSimilarString(inWords, "electronics", MIN_WORD_SIMILARITY)).thenReturn(false); when(similarityChecker.containsSimilarString(inWords, "departments", MIN_WORD_SIMILARITY)).thenReturn(false); when(similarityChecker.containsSimilarString(inWords, "university", MIN_WORD_SIMILARITY)).thenReturn(true); when(similarityChecker.containsSimilarString(inWords, "warsaw", MIN_WORD_SIMILARITY)).thenReturn(true); double similarWordRatio = calculator.calcSimilarWordRatio(findWords, inWords); assertEquals(0.5, similarWordRatio, 0.000001); }
public double calcSimilarWordRatio(List<String> findWords, List<String> inWords) { return (double)calcSimilarWordNumber(findWords, inWords) / findWords.size(); }
CommonSimilarWordCalculator implements Serializable { public double calcSimilarWordRatio(List<String> findWords, List<String> inWords) { return (double)calcSimilarWordNumber(findWords, inWords) / findWords.size(); } }
CommonSimilarWordCalculator implements Serializable { public double calcSimilarWordRatio(List<String> findWords, List<String> inWords) { return (double)calcSimilarWordNumber(findWords, inWords) / findWords.size(); } CommonSimilarWordCalculator(double minWordSimilarity); }
CommonSimilarWordCalculator implements Serializable { public double calcSimilarWordRatio(List<String> findWords, List<String> inWords) { return (double)calcSimilarWordNumber(findWords, inWords) / findWords.size(); } CommonSimilarWordCalculator(double minWordSimilarity); int calcSimilarWordNumber(List<String> findWords, List<String> inWords); double calcSimilarWordRatio(List<String> findWords, List<String> inWords); void setMinWordSimilarity(float minWordSimilarity); void setSimilarityChecker(StringSimilarityChecker similarityChecker); @Override String toString(); }
CommonSimilarWordCalculator implements Serializable { public double calcSimilarWordRatio(List<String> findWords, List<String> inWords) { return (double)calcSimilarWordNumber(findWords, inWords) / findWords.size(); } CommonSimilarWordCalculator(double minWordSimilarity); int calcSimilarWordNumber(List<String> findWords, List<String> inWords); double calcSimilarWordRatio(List<String> findWords, List<String> inWords); void setMinWordSimilarity(float minWordSimilarity); void setSimilarityChecker(StringSimilarityChecker similarityChecker); @Override String toString();  }