就是实现对一个txt文档就行分词,用庖丁中文分词器。给出代码。最好给出解释
3条回答 默认 最新
- weixin_42317583 2009-07-24 17:36关注
知道paoding就应该知道Lucene,可以用Lucene的分词器Analyzer,代码如下,测试加入lucene包和paoding配置即可
Analyzer analyzer = new PaodingAnalyzer();
FileInputStream in = null;
in = new FileInputStream(new File("d://1.txt"));
InputStreamReader inReader = new InputStreamReader(in);
BufferedReader br = new BufferedReader(inReader);
TokenStream ts = analyzer.tokenStream(content, br);
Token t = ts.next();
while (t != null) {
contentAnalyzer += t.termText() + " ";
System.out.println(t.termText());
t = ts.next();
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 matlab数据降噪处理,提高数据的可信度,确保峰值信号的不损失?
- ¥15 怎么看我在bios每次修改的日志
- ¥15 python+mysql图书管理系统
- ¥15 Questasim Error: (vcom-13)
- ¥15 船舶旋回实验matlab
- ¥30 SQL 数组,游标,递归覆盖原值
- ¥15 为什么我的数据接收的那么慢呀有没有完整的 hal 库并 代码呀有的话能不能发我一份并且我用 printf 函数显示处理之后的数据,用 debug 就不能运行了呢
- ¥20 gitlab 中文路径,无法下载
- ¥15 用动态规划算法均分纸牌
- ¥30 udp socket,bind 0.0.0.0 ,如何自动选取用户访问的服务器IP来回复数据