JiebaSegmenter.cs 877 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using JiebaNet.Segmenter;
  4. namespace wispro.sp.utility
  5. {
  6. public class Jieba_Segmenter
  7. {
  8. private readonly JiebaSegmenter _segmenter;
  9. public Jieba_Segmenter()
  10. {
  11. _segmenter = new JiebaSegmenter();
  12. }
  13. public List<string> Cut(string text)
  14. {
  15. // 精确模式
  16. var words = _segmenter.Cut(text);
  17. return words.ToList();
  18. }
  19. public List<string> CutForSearch(string text)
  20. {
  21. // 搜索引擎模式
  22. var words = _segmenter.CutForSearch(text);
  23. return words.ToList();
  24. }
  25. public List<string> CutAll(string text)
  26. {
  27. // 全模式
  28. var words = _segmenter.Cut(text,true,true);
  29. return words.ToList();
  30. }
  31. }
  32. }