Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

default.dic等字典可以放在resource下面读取? #716

Closed
luoyexuge opened this issue Mar 19, 2019 · 21 comments
Closed

default.dic等字典可以放在resource下面读取? #716

luoyexuge opened this issue Mar 19, 2019 · 21 comments

Comments

@luoyexuge
Copy link

No description provided.

@luoyexuge
Copy link
Author

这个字典是否可以放在resource下面读取,这样可以直接打包在ansj jar包里面 ,在第三方mvn项目依赖这个 也不需要额外增加动态做配置?

@ekoz
Copy link

ekoz commented Mar 21, 2019

please read 加载词典的方式 5.1.0版本之后

@hujian0923
Copy link

请问一下,我按照上面的方式,把字典文件全部放到resource/library下,然后在resource/library.properties中配置了相对路径,但是不启作用。日志中还是报ERROR错误,但是我换成绝对路径,就可以。这个能解决吗?绝对路径这种方法是不可行的。

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

加了的。我的项目是父子maven项目,但是日志提示是需要到父项目的根目录下的library目录下

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

那请问能设置相对路径吗?

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

wiki中https://github.com/NLPchina/ansj_seg/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E 中写的是相对路径,我按照这个试了,但是不行

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

我的意思是library.properties在maven项目的resource目录下,然后我把字典文件放到resource/library/目录下,然后配置的dic=library/default.dic。但是不行的

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

我测试了,library.properties文件在子项目的resource下,配置的dic=子项目名称/resources/library/default.dic.
还是报错00:08:53,298 ERROR org.ansj.library.DicLibrary - Init ambiguity library error :org.ansj.exception.LibraryException: path :子项目名称/resources/library/default.dic file:E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic not found or can not to read, path: 子项目名称/resources/library/default.dic

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

我要是写成dic=E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic 。 这样写绝对路径就没有问题

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

不好意思,刚才说错了 dic=E:\IDEA\workspace\父项目名称\子项目名称/src/main/resources/library/default.dic 这样写就没有问题,但是我想写成dic=library/default.dic这样,然后直接在子项目的resource中去找。不知道能不能实现这种

@ansjsun
Copy link
Member

ansjsun commented May 5, 2019 via email

@hujian0923
Copy link

好的,明白了,多谢。有点晚了,不好意思。

@ansjsun ansjsun closed this as completed Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants