Esempio n. 1
0
 public double CalculateDistance(ITermWeightRepresentation termWeightRepresentation,
                                 TermsCollection termsCollection)
 {
     double sum = 0;
     foreach (string term in termsCollection.Terms)
     {
         sum += Math.Pow(termWeightRepresentation.TermWeight(term), 2);
     }
     return Math.Sqrt(sum);
 }
Esempio n. 2
0
        public double CalculateProbability(ITermWeightRepresentation queryRepresentation,
                                           ITermWeightRepresentation documentRepresentation,
                                           TermsCollection termsCollection)
        {
            double queryDistance = _distanceCalculator.CalculateDistance(queryRepresentation, termsCollection);
            double documentDistance = _distanceCalculator.CalculateDistance(documentRepresentation, termsCollection);

            double sum = 0;
            foreach (string term in termsCollection.Terms)
            {
                sum += queryRepresentation.TermWeight(term)*documentRepresentation.TermWeight(term);
            }
            return sum/(queryDistance*documentDistance);
        }
Esempio n. 3
0
File: TfIdf.cs Progetto: psla/tfidf
 /// <summary>
 /// 
 /// </summary>
 /// <param name="termWeightRepresentation">should be instance of <see cref="Tf"/></param>
 /// <param name="idf"></param>
 public TfIdf(ITermWeightRepresentation termWeightRepresentation, IIdf idf)
 {
     _termWeightRepresentation = termWeightRepresentation;
     _idf = idf;
 }