HanLP.NET 0.5.8.6

dotnet add package HanLP.NET --version 0.5.8.6
                    
NuGet\Install-Package HanLP.NET -Version 0.5.8.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HanLP.NET" Version="0.5.8.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HanLP.NET" Version="0.5.8.6" />
                    
Directory.Packages.props
<PackageReference Include="HanLP.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HanLP.NET --version 0.5.8.6
                    
#r "nuget: HanLP.NET, 0.5.8.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HanLP.NET@0.5.8.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HanLP.NET&version=0.5.8.6
                    
Install as a Cake Addin
#tool nuget:?package=HanLP.NET&version=0.5.8.6
                    
Install as a Cake Tool

HanLP.NET,all C# sourcecode HanLP,no-wrapper

1 HanLP vs HanLP.NET

1.1 HanLP

自然语言处理包HanLP具备中文分词、词性标注、关键词提取、自动摘要、依存句法分析、命名实体识别、短语提取、拼音转换、简繁转换等等功能。 HanLP从开源起步,发展顺利,应用广泛,更多的介绍请访问: HanLP官网:https://www.hanlp.com/semantics/dashboard/index HanLP开源:https://github.com/hankcs/HanLP

1.2 HanLP.NET

HanLP.NET是全C#版HanLP,非包装型(no-wrapper)。 (1)翻译:源自 HanLP Java 1.8.6,不小改造。 (2)代码:100%纯C#代码,无需 JDK, IKVM 支持。 (3)版本:本版本的程序库适配.NET 10, Windows 10+,X64平台。 (3)定制:需适配其他CPU,其他操作系统(Linux,国产系统)的类库,请联系作者修改、编译,或者获取全部源代码。

2 关于HanLP.NET项目

2.1 类库的独立性

HanLP.NET 可脱离 Java,Python 环境,融入.NET生态,方便地构建:桌面软件,工业软件,Linux,统信系统,手机(安卓,iOS,鸿蒙等),机器人,具身智能,ARM平台等等。HanLP.NET是完全自主可控的、工业软件级别的NLP底座。 HanLP.NET 是轻量化的 NLP 底座,仅需几十 MB 即可构建功能优异的 NLP 应用。

2.2 告示

(1)未翻译训练 train 相关的代码。 (2)未翻译管道 pipeline 相关的代码。

2.3 HanLP.NET 改进

(1)重新训练与处理了个别错误的数据; (2)支持 json 文件进行字典、模型 加载的设置; (3)改造了字典、模型 加载算法; (4)改造了不少 java 代码;

3 HanLP.NET主要功能

HanLP.NET 包括下面几大类功能:

(1)分词:默认分词;Viterbi;双数组trie树;CRF条件随机场;感知机分词;标准分词;索引分词;N-最短分词;Dijkstra;极速分词;自定义词典;感知机词法分析; (2)自动摘要;关键词提取;短语提取;新词发现;人名识别;机构名识别;数词和数量词识别;词性标注; (3)拼音转换;简繁转换:简体,(大陆)繁体;台湾繁体;香港繁体; (4)依存句法分析:支持绘制与输出图形; (5)语义推荐;同义词改写;情感分析; (6)语义距离;词共现统计;文本聚类;

相应的函数与HanLP同名。

请从下面的网址下载测试代码,了解全部功能。 https://gitee.com/hanlp_net/demo

4 怎么用 HanLP.NET

4.1 准备 HanLP 数据

请自行下载 HanLP 数据(653MB),并解压至(为) data 文件夹(dictionary + model)或其他文件夹。 HanLP官网(HanLP 1.7.5 数据包)::https://file.hankcs.com/hanlp/data-for-1.7.5.zip 其中个别数据有错,HanLP.NET 0.5.5.0 版本之后能自动处理。 百度网盘(已修正错误数据):https://pan.baidu.com/s/1rq5ZfrRDGX677fkboNvFoQ?pwd=1vti (记得把 bin 后缀改为 zip,再解压。)

ChnSentiCorp情感分析酒店评论数据集:http://file.hankcs.com/corpus/ChnSentiCorp.zip

4.2 指定数据源

将测试代码中的 hanlp-data-config.json 文件保存于 exe 同一个文件夹。 可设置成:仅仅加载必须的字典与模型; 例如:DataPath 数据 data 根文件夹(根目录) 字段。 其他在说明在 json 文件内有中文说明。

4.3 预加载字典、模型

//预读取字典,模型数据;得到可能的错误信息; string err = HanLP.init();

4.4 调用接口实现相应功能(例如:分词)

string text = @"我新造一个词叫幻想乡你能识别并标注正确词性吗?"; List<Term> words = NLPTokenizer.segment(text); 更多接口请阅读测试代码。

5 联系我们

Hanlp.NET可支持各类别或版本:.Frameworks,.NET,国产系统,CPU ... 如果您需要适配类型CPU、操作系统的类库,可联系联高软件。 http://www.315soft.com

6 版权

LPT 版权归原作者。 HanLP 版权归于原作者; HanLP源代码的授权协议为 Apache License 2.0,可免费用做商业用途。 请在产品说明中附加HanLP的链接和授权协议。 HanLP.NET 代码版权归北京联高软件开发有限公司

Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.17763 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.8.6 129 5/31/2026
0.5.8.3 117 5/28/2026
0.5.5.7 107 5/18/2026
0.5.2.1 105 5/16/2026
0.5.2 109 5/16/2026