Cut() public method

The main function that segments an entire sentence that contains Chinese characters into seperated words.
public Cut ( string text, bool cutAll = false, bool hmm = true ) : IEnumerable
text string The string to be segmented.
cutAll bool Specify segmentation pattern. True for full pattern, False for accurate pattern.
hmm bool Whether to use the Hidden Markov Model.
return IEnumerable
Example #1
0
        public static void Run() {
            while (true) {

                var str = Console.ReadLine();
                var segmenter = new JiebaSegmenter();
                var segments = segmenter.Cut(str, cutAll: true);
                Console.WriteLine("【全模式】:{0}", string.Join("/ ", segments));

                segments = segmenter.Cut(str); // 默认为精确模式
                Console.WriteLine("【精确模式】:{0}", string.Join("/ ", segments));

                segments = segmenter.Cut(str); // 默认为精确模式,同时也使用HMM模型
                Console.WriteLine("【新词识别】:{0}", string.Join("/ ", segments));

                segments = segmenter.CutForSearch(str); // 搜索引擎模式
                Console.WriteLine("【搜索引擎模式】:{0}", string.Join("/ ", segments));

                segments = segmenter.Cut(str);
                Console.WriteLine("【歧义消除】:{0}", string.Join("/ ", segments));
            }
        }