예제 #1
0
파일: Sentence.cs 프로젝트: Ran-QUAN/Alta
 /// <summary>
 /// 删除一个分词。
 /// </summary>
 /// <param name="word">要删除的分词</param>
 public void RemoveWord(Word word)
 {
     lock (_words)
     {
         _words.Remove(word);
     }
 }
예제 #2
0
파일: Sentence.cs 프로젝트: Ran-QUAN/Alta
        /// <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);
                    }
                }
            }
        }
예제 #3
0
파일: Entity.cs 프로젝트: Ran-QUAN/Alta
        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;
                }
            }
        }
예제 #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);
                }
            }
예제 #5
0
파일: Entity.cs 프로젝트: Ran-QUAN/Alta
        public void RemoveWord(Word word)
        {
            if (word == null)
                return;

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