Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

怎么打包能让词典放在外面方便修改? #72

Closed
oovm opened this issue Sep 12, 2018 · 4 comments
Closed

怎么打包能让词典放在外面方便修改? #72

oovm opened this issue Sep 12, 2018 · 4 comments

Comments

@oovm
Copy link

oovm commented Sep 12, 2018

打包为 jar, 如何修改才能读取外面的词典.

我打包直接去掉资源文件就找不到词典了.

@YLongo
Copy link

YLongo commented Sep 12, 2018

你把 word.conf 配置中的词典路径改成你外部词典的路径就可以了

@oovm
Copy link
Author

oovm commented Sep 12, 2018

似乎不支持相对路径.

dic.txt 和 jar 放在同目录, dic.txt, ./dic.txt, ./../dic.txt 均无法读取.

@YLongo
Copy link

YLongo commented Sep 12, 2018

你都放到 jar 外面了,当然要使用绝对路径

@oovm
Copy link
Author

oovm commented Sep 12, 2018

因为 HanLP 是用相对地址配置的, 然后觉得这应该是差不多的.

hankcs/HanLP#380

然后发现设计思路还是差很多的...

java.nio.file 必须使用 URL, 所以得写绝对路径.

Files.lines(Paths.get("dic.txt"));

改成

(Stream<String>) new FileInputStream(new File("dic.txt"));

首次读取成功, 但是还是会有别的问题...


改用网络地址了, 要改的地方太多了, 不折腾了...

而且网络比本地灵活多了...

@oovm oovm closed this as completed Sep 12, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants