HanLP icon indicating copy to clipboard operation
HanLP copied to clipboard

hanlp-portable 怎样通过properties 文件配置自定义词典呢。

Open chenruiSundun opened this issue 9 years ago • 21 comments

chenruiSundun avatar Mar 10 '17 06:03 chenruiSundun

#425

cicido avatar Mar 13 '17 03:03 cicido

protable 版内置了词典的,问题是怎么去覆盖内置的此单,转为用 properties 文件去指定。

chenruiSundun avatar Mar 13 '17 03:03 chenruiSundun

修改properties文件后,重新打包. java -cvf

cicido avatar Mar 13 '17 03:03 cicido

我最近把data文件打成一个jar包, hanlp.properties打成一个jar包。并增加了一个JarIOAdapter文件,在 corpus/io下。现在能完美的在spark下面跑了。跑的时候,提交这三个包就行。词典的增删操作把以前方便多了。

cicido avatar Mar 13 '17 03:03 cicido

我是集成到ES 里面作为 一个插件

chenruiSundun avatar Mar 13 '17 03:03 chenruiSundun

哦,我这里考虑的更方便的对词典进行增删操作

cicido avatar Mar 13 '17 03:03 cicido

protable 版默认不会去读 properties 文件,

chenruiSundun avatar Mar 13 '17 03:03 chenruiSundun

properties文件提定的是外部文件位置。

cicido avatar Mar 13 '17 03:03 cicido

是的,都是设置好的了

cicido avatar Mar 13 '17 03:03 cicido

你可以把里面的data文件夹替换掉就好了

cicido avatar Mar 13 '17 03:03 cicido

再重新打个jar包,直接用jar命令打,很方便很快

cicido avatar Mar 13 '17 03:03 cicido

你知道 protable 版的源码么 ,要有源码就好了

chenruiSundun avatar Mar 13 '17 03:03 chenruiSundun

有吧,你切一下分支,好像就可以了

cicido avatar Mar 13 '17 03:03 cicido

portable分支与master分支在这一点上似乎是一样的

cicido avatar Mar 13 '17 03:03 cicido

额 ,没注意到 还有一protable 分支 ,谢谢你!

chenruiSundun avatar Mar 13 '17 03:03 chenruiSundun

ok

cicido avatar Mar 13 '17 03:03 cicido

我下载 了protable 分支 ,将 data 文件夹复制到resources 文件夹下,编译能成功,但是在ES 里面 run的时候 ,报错。。

chenruiSundun avatar Mar 13 '17 05:03 chenruiSundun

data文件要提前跑一下,以生成相应的bin或data后缀的词典文件,另外我发现Chartype.txt这个配置有问题。由于protable是不带hanlp.properties文件,那默认的就是那些static变量配置,那CharTypePath配的是CharType.bin文件,不是CharType.txt.bin. 而1.3.2对应的data是CharType.data.yes.这个你要具体看下。

cicido avatar Mar 20 '17 01:03 cicido

portable版本感觉应该要增加一个配置, 可以进一步读取自定义词典

tankle avatar Dec 13 '17 11:12 tankle

我最近把data文件打成一个jar包, hanlp.properties打成一个jar包。并增加了一个JarIOAdapter文件,在 corpus/io下。现在能完美的在spark下面跑了。跑的时候,提交这三个包就行。词典的增删操作把以前方便多了。

@cicido 你好,试了一下直接别的方法,没有成功,看到你的这个方法,麻烦问下这个是怎么操作的么,有没有文章说明一下的

zhweizhang avatar Nov 08 '18 04:11 zhweizhang