コード例 #1
0
 public static HashSet<Word> addToVocabulary(List<string> words, HashSet<Word> vocabulary)
 {
     foreach (string word in words)
     {
         Word w = new Word(word);
         if (!vocabulary.Contains(w))
             vocabulary.Add(w);
     }
     return vocabulary;
 }
コード例 #2
0
        public static bool isRelevantText(List<string> keyWords, HashSet<Word> vocabulary)
        {
            double prob = 0;
            double size = keyWords.Count;
            if (size == 0)
                return true;

            double i = 0;
            foreach (string word in keyWords)
            {
                Word w = new Word(word);
                if (vocabulary.Contains(w))
                    i++;
            }
            prob = i / size;
            Console.WriteLine("Match = " + prob);
            return (prob >= MIN_PROB);
        }