JiebaNet.Segmenter.Common.Trie.Insert C# (CSharp) Method

Insert() public method

public Insert ( string word, int freq = 1 ) : int
word string
freq int
return int
        public int Insert(string word, int freq = 1)
        {
            CheckWord(word);

            var i = Root.Insert(word.Trim(), 0, freq);
            if (i > 0)
            {
                TotalFrequency += freq;
                Count++;
            }

            return i;
        }

Usage Example

Example #1
0
 private Trie GetWordDictTrie()
 {
     var wordDict = WordDictionary.Instance;
     var trie = new Trie();
     foreach (var wd in wordDict.Trie)
     {
         if (wd.Value > 0)
         {
             trie.Insert(wd.Key, wd.Value);
         }
     }
     return trie;
 }
All Usage Examples Of JiebaNet.Segmenter.Common.Trie::Insert