wordFrequencySimilarity function

double wordFrequencySimilarity (
  1. String document1,
  2. String document2,
  3. {dynamic distanceFunction: cosineDistance,
  4. String stemmer(
    1. String
    ),
  5. List<String> stopwords}
)

Check similarity between 2 documents using word frequency metric

Default distanceFunction is cosineDistance

Implementation

double wordFrequencySimilarity(String document1, String document2,
    {distanceFunction = cosineDistance,
    String Function(String) stemmer,
    List<String> stopwords}) {
  List<List<double>> vectorList = wordFrequencyMatrix([document1, document2],
      stemmer: stemmer, stopwords: stopwords);

  return 1.0 - distanceFunction(vectorList[0], vectorList[1]);
}