Exemplo n.º 1
0
 private void PopulateOverallTermFrequency(List <Term> sortedTerms)
 {
     for (int i = 0; i < sortedTerms.Count; i++)
     {
         // If the dictionary contains the term, we want to increment for each document it appears on.
         // We do this by comparing the id to the id of the previous element. If they differ we increment.
         if (TermFrequency.ContainsKey(sortedTerms[i].Word))
         {
             TermFrequency[sortedTerms[i].Word]++;
         }
         else
         {
             TermFrequency.Add(sortedTerms[i].Word, 1);
         }
     }
 }
Exemplo n.º 2
0
 public void CalTF()
 {
     foreach (Token token in Tokens)
     {
         if (token.WordType == Token.WORDTYPE.REGULAR)
         {
             if (!TermFrequency.ContainsKey(token.ProcessedContent))
             {
                 TermFrequency.Add(token.ProcessedContent, 1);
             }
             else
             {
                 TermFrequency[token.ProcessedContent]++;
             }
         }
     }
 }