Exemple #1
0
 /// <summary>
 /// 删除一个分词。
 /// </summary>
 /// <param name="word">要删除的分词</param>
 public void RemoveWord(Word word)
 {
     lock (_words)
     {
         _words.Remove(word);
     }
 }
Exemple #2
0
        /// <summary>
        /// 在分句内标注一个分词。
        /// </summary>
        /// <param name="word">要标注的分词</param>
        public void AnnotateWord(Word word)
        {
            lock (_words)
            {
                if (word == null)
                    return;

                if (word is Entity)
                {
                    AnnotateEntity((Entity)word);
                }
                else
                {
                    int index = _words.BinarySearch(word, s_wordComparer);

                    if (index < 0)
                    {
                        word.Context = this;
                        _words.Insert(~index, word);
                    }
                }
            }
        }
Exemple #3
0
        public void AnnotateWord(Word word)
        {
            if (word == null)
                return;

            if (_words == null)
            {
                _words = new List<Word>();
            }

            if (word is Entity)
            {
                AnnotateEntity((Entity)word);
            }
            else
            {
                int index = _words.BinarySearch(word, Sentence.WordComparer);

                if (index < 0)
                {
                    _words.Insert(~index, word);
                    word.Context = this.Context;
                }
            }
        }
Exemple #4
0
            public void CreateWord()
            {
                bool append = _sentence != null;

                createSentenceIfNull();

                if (!append)
                    _sentence.Content = LastInput.ToString();
                else
                    _sentence.Content += LastInput.ToString();

                _lastCharSentenceIndex++;

                Word word    = new Word(_lastCharSentenceIndex, 1, 0);
                word.Context = _sentence;

                if (_entity.Count > 0)
                {
                    _entity.Peek().AnnotateWord(word);

                    foreach (var e in _entity)
                    {
                        e.Length++;
                    }
                }
                else
                {
                    _sentence.AnnotateWord(word);
                }
            }
Exemple #5
0
        public void RemoveWord(Word word)
        {
            if (word == null)
                return;

            if (_words != null)
                _words.Remove(word);
        }