论坛
门户
内部优惠
喜欢
话题
VIP会员
搜索
新浪微博
登录
注册
100%
100%
首页
>
网络技术
>
网络技术
>
spark集群使用hanlp进行分布式分词操作说明
回复
« 返回列表
hadoop小学生
精灵王
注册日期
2018-09-13
发帖数
160
QQ
3234520070
火币
360枚
粉丝
0
关注
0
加关注
写私信
打招呼
阅读:
4364
回复:
0
spark集群使用hanlp进行分布式分词操作说明
楼主
#
更多
只看楼主
倒序阅读
发布于:2019-01-21 10:37
保存
100%
100%
[]
1
本篇分享一个使用
hanlp分词
的操作小案例,即在
spark
集群中使用
hanlp
完成分布式
分词
的操作,文章整理自【
qq
_33872191
】的博客,感谢分享!以下为全文:
分两步:
第一步:实现
hankcs.hanlp/corpus.io.IIOAdapter
图片:图1.jpg
1.
public class
hadoop
FileIoAdapter implements IIOAdapter {
2.
3.
@Override
4.
public InputStream open(String path) throws IOException {
5.
Configuration conf = new Configuration();
6.
FileSystem fs = FileSystem.get(URI.create(path), conf);
7.
return fs.open(new Path(path));
8.
}
9.
10.
@Override
11.
public OutputStream create(String path) throws IOException {
12.
Configuration conf = new Configuration();
13.
FileSystem fs = FileSystem.get(URI.create(path), conf);
14.
OutputStream out = fs.create(new Path(path));
15.
return out;
16.
}
17.
}
第二步:修改配置文件。
root
为
hdfs
上的数据包,把
IOAdapter
改为咱们上面实现的类
图片:图2.jpg
图片:图3.jpg
ok
,这样你就能在分布式集群上使用
hanlp
进行分词了。
整个步骤比较简单,欢迎各位大神交流探讨!
喜欢
0
评分
0
最新喜欢:
DKHadoop用着还不错!
回复
100%
发帖
回复
« 返回列表
普通帖
您需要登录后才可以回帖,
登录
或者
注册
100%
返回顶部
关闭
最新喜欢