/// <summary> /// 删除一个分词。 /// </summary> /// <param name="word">要删除的分词</param> public void RemoveWord(Word word) { lock (_words) { _words.Remove(word); } }
/// <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); } } } }
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; } } }
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); } }
public void RemoveWord(Word word) { if (word == null) return; if (_words != null) _words.Remove(word); }