Beispiel #1
0
 /// <summary>
 /// Caculate P(word|tag)
 /// </summary>
 /// <param name="word"></param>
 public double GetProbabilityWordGivenTag(Word word)
 {
     if (AssociatedWordDict.ContainsKey(word))
     {
         return (double) AssociatedWordDict[word]/TagCount;
     }
     return 0;
 }
Beispiel #2
0
 public void AddWord(Word word)
 {
     if (AssociatedWordDict.ContainsKey(word))
     {
         //add 1 count
         AssociatedWordDict[word]++;
     }
     else
     {
         //and new tag into dictionary
         AssociatedWordDict.Add(word, 1);
     }
     TagCount++;
 }
Beispiel #3
0
 /// <summary>
 /// Caculate P(word|tag)
 /// </summary>
 /// <param name="word"></param>
 /// <param name="tag"></param>
 private double GetProbabilityTagGivenWord(Word word, Tag tag)
 {
     return (word.GetProbabilityTagGivenWord(tag));
 }
Beispiel #4
0
 /// <summary>
 /// Caculate P(word|tag)
 /// </summary>
 /// <param name="word"></param>
 /// <param name="tag"></param>
 private double GetProbabilityWordGivenTag(Word word, Tag tag)
 {
     return (tag.GetProbabilityWordGivenTag(word));
 }
Beispiel #5
0
 public Word AddWord(string word)
 {
     if (WordDict.ContainsKey(word))
     {
         return WordDict[word];
     }
     var newWord = new Word { Value = word };
     WordDict.Add(word, newWord);
     return newWord;
 }