利用OpenNLP进行英文段落的分句
安装
Install-Package OpenNLP
Install-Package System.Runtime.Caching
示例代码
using OpenNLP.Tools.SentenceDetect;
var paragraph = @"To test easily the various NLP tools, run the ToolsExample winform project. You'll find below a more detailed description of the tools and how code snippets to use them directly in your code. All NLP tools based on the maxent algorithm need model files to run. You'll find those files for English in Resources/Models. If you want to train your own models (to improve precision on English or to use those tools on other languages), please refer to the last section.";
var modelPath = "EnglishSD.nbin";
var sentenceDetector = new EnglishMaximumEntropySentenceDetector(modelPath);
var sentences = sentenceDetector.SentenceDetect(paragraph);
if (sentences?.Length > 0)
{
foreach (var sentence in sentences)
{
Console.WriteLine(sentence);
}
}
Console.ReadKey();
注:上面代码中用到的EnglishSD.nbin文件,在官方的源码里面有,可以直接复制到自己的工程里。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
2017-09-12 通过NLayer和NAudio转换MP3成WAV
2017-09-12 使用NAudio实现Wav转Mp3
2017-09-12 SynchronizationContext笔记