Пример #1
0
        public void Add(Ngram ngram, int word = 0, int level = 0)
        {
            if (level >= ngram.Words[word].Length)
            {
                word++;
                level = 0;

                if (ngram.Words.Length < (word + 1))
                {
                    Occurences = ngram.Frequency;
                    return;
                }
            }

            foreach (NgramNode node in nodes)
            {
                if (node.Key == ngram.Words[word][level])
                {
                    node.Add(ngram, word, ++level);
                    return;
                }
            }

            NgramNode newNode = new NgramNode(ngram.Words[word][level], word);
            nodes.Add(newNode);
            newNode.Add(ngram, word, ++level);
        }
Пример #2
0
        public void Add(Ngram ngram)
        {
            NgramCount += ngram.Frequency;
            UniqueNgrams++;

            ngramTree.Add(ngram);
        }