代码拉取完成,页面将自动刷新
using JiebaNet.Segmenter;
using System;
using System.Collections.Generic;
namespace OpenCCNET
{
public static partial class ZhConverter
{
public static class ZhSegment
{
/// <summary>
/// 语句分词
/// </summary>
public static Func<string, IEnumerable<string>> Segment = SegmentByJieba;
/// <summary>
/// jieba.NET分词
/// </summary>
public static JiebaSegmenter Jieba = new JiebaSegmenter();
public static void Initialize(string jiebaResourceDirectory = "JiebaResource")
{
ConfigManager.ConfigFileBaseDir = jiebaResourceDirectory;
// 通过调用一次jieba分词来提前加载所需资源
Jieba.Cut(string.Empty);
}
/// <summary>
/// 利用jieba.NET分词
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
private static IEnumerable<string> SegmentByJieba(string text)
{
return Jieba.Cut(text);
}
/// <summary>
/// 重置分词所用方法
/// </summary>
public static void ResetSegment()
{
Segment = SegmentByJieba;
Jieba = new JiebaSegmenter();
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。