1 Star 7 Fork 0

积雨云/OpenCC.NET

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ZhSegment.cs 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
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();
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/cosineg/opencc-net.git
git@gitee.com:cosineg/opencc-net.git
cosineg
opencc-net
OpenCC.NET
master

搜索帮助