public void TestViterbi() { var result = _hhmAlgorithm.Core(@"杭研杭研杭研"); var segment = string.Join("/", result); Assert.AreEqual("杭研/杭研/杭研", segment); result = _hhmAlgorithm.Core(@"杭杭研杭研"); segment = string.Join("/", result); Assert.AreEqual("杭杭研/杭研", segment); result = _hhmAlgorithm.Core(@"研杭杭研杭研"); segment = string.Join("/", result); Assert.AreEqual("研杭/杭研/杭研", segment); }
public virtual void ResolveGapWords(List <string> result, StringBuilder sb) { if (sb.Length > 0) { string word = sb.ToString(); if (word.Length > 1 && !WordDictionary.HasEffectiveKey(word)) { result.AddRange(Algorithm.Core(word)); } else { result.Add(word); } sb.Clear(); } }