コード例 #1
0
 private static void GradeSentences(Article article)
 {
     foreach (Sentence sentence in article.Sentences)
     {
         foreach (Word word in sentence.Words)
         {
             string wordstem      = Stemmer.StemStrip(word.Value, article.Rules);
             Word   importantWord = article.ImportantWords.Find(delegate(Word match) {
                 return(match.Stem == wordstem);
             });
             if (importantWord != null)
             {
                 sentence.Score++;
             }
         }
     }
 }
コード例 #2
0
        private void AddWordCount(string word)
        {
            Word stemmedWord = Stemmer.StemWord(word, this.Rules);

            if (word == null || word == string.Empty || word == " " || word == "\n" || word == "\t")
            {
                return;
            }
            Word foundWord = WordCounts.Find(delegate(Word match) {
                return(match.Stem == stemmedWord.Stem);
            });

            if (foundWord == null)
            {
                WordCounts.Add(stemmedWord);
            }
            else
            {
                foundWord.TermFrequency++;
            }
        }