Example #1
0
 public TrieTreeNode AddWord(string word, double frequency, POSType pos)
 {
     if (word.Length == 1)
     {
         return(AddWord(word[0], frequency, pos));
     }
     else
     {
         char[]       chars = word.ToCharArray();
         TrieTreeNode node  = _root;
         for (int i = 0; i < chars.Length; i++)
         {
             TrieTreeNode newnode = node.AddChild(chars[i]);
             node = newnode;
         }
         if (frequency == double.NaN)
         {
             node.IncreaseFrequency();
         }
         else
         {
             node.Frequency += frequency;
         }
         node.WordEnded = true;
         if (pos != POSType.UNKNOWN && pos != POSType.NEWLINE)
         {
             node.AddPOS(pos);
         }
         return(node);
     }
 }
Example #2
0
        internal TrieTreeNode AddWord(char ch, double frequency, bool isWordEnded, POSType pos)
        {
            TrieTreeNode newnode = _root.AddChild(ch);

            if (frequency == double.NaN)
            {
                newnode.IncreaseFrequency();
            }
            else
            {
                newnode.Frequency += frequency;
            }
            newnode.WordEnded = true;
            if (pos != POSType.UNKNOWN && pos != POSType.NEWLINE)
            {
                newnode.AddPOS(pos);
            }
            return(newnode);
        }