-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Comments
这个字典是否可以放在resource下面读取,这样可以直接打包在ansj jar包里面 ,在第三方mvn项目依赖这个 也不需要额外增加动态做配置? |
please read 加载词典的方式 5.1.0版本之后 |
请问一下,我按照上面的方式,把字典文件全部放到resource/library下,然后在resource/library.properties中配置了相对路径,但是不启作用。日志中还是报ERROR错误,但是我换成绝对路径,就可以。这个能解决吗?绝对路径这种方法是不可行的。 |
resource目录没加到cp里面吧? 看日志有加载路径提示 仔细看
在2019年05月05日 23:44,hujian 写道:
请问一下,我按照上面的方式,把字典文件全部放到resource/library下,然后在resource/library.properties中配置了相对路径,但是不启作用。日志中还是报ERROR错误,但是我换成绝对路径,就可以。这个能解决吗?绝对路径这种方法是不可行的。
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
加了的。我的项目是父子maven项目,但是日志提示是需要到父项目的根目录下的library目录下 |
这个 可以启动的时候 通过MyStaticValue. 来直接设置properties路径 好像是 不行你看看wiki
在2019年05月05日 23:49,hujian 写道:
加了的。我的项目是父子maven项目,但是日志提示是需要到父项目的根目录下的library目录下
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
那请问能设置相对路径吗? |
相对路径 就是你project的根目录
在2019年05月05日 23:53,hujian 写道:
那请问能设置相对路径吗?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
相对路径和运行环境有关
在2019年05月05日 23:54,ansj 写道:
相对路径 就是你project的根目录
在2019年05月05日 23:53,hujian 写道:
那请问能设置相对路径吗?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
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 中写的是相对路径,我按照这个试了,但是不行 |
相对路径 是你 项目根目录 你得找到相对路径的根目录在哪里再放
在2019年05月05日 23:55,hujian 写道:
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 中写的是相对路径,我按照这个试了,但是不行
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
我的意思是library.properties在maven项目的resource目录下,然后我把字典文件放到resource/library/目录下,然后配置的dic=library/default.dic。但是不行的 |
你得把相对路径设置为 项目名称/resource/library/xxx.dic
在2019年05月05日 23:59,hujian 写道:
我的意思是library.properties在maven项目的resource目录下,然后我把字典文件放到resource/library/目录下,然后配置的dic=library/default.dic。但是不行的
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
你的项目 是maven子模块 所以相对路径 要有子模块目录名称
在2019年05月06日 00:00,ansj 写道:
你得把相对路径设置为 项目名称/resource/library/xxx.dic
在2019年05月05日 23:59,hujian 写道:
我的意思是library.properties在maven项目的resource目录下,然后我把字典文件放到resource/library/目录下,然后配置的dic=library/default.dic。但是不行的
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
我测试了,library.properties文件在子项目的resource下,配置的dic=子项目名称/resources/library/default.dic. |
E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic。这个路径不对?
在2019年05月06日 00:08,hujian 写道:
我测试了,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
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
我要是写成dic=E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic 。 这样写绝对路径就没有问题 |
E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic。你仔细检查下 是不是你路径写错了 不应该的
在2019年05月06日 00:12,hujian 写道:
我要是写成dic=E:\IDEA\workspace\父项目名称\子项目名称\resources\library\default.dic 。 这样写绝对路径就没有问题
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
不好意思,刚才说错了 dic=E:\IDEA\workspace\父项目名称\子项目名称/src/main/resources/library/default.dic 这样写就没有问题,但是我想写成dic=library/default.dic这样,然后直接在子项目的resource中去找。不知道能不能实现这种 |
不行 idea 绝对路径只能是根目录 除非你把子模块当一个项目 放到根目录
在2019年05月06日 00:19,hujian 写道:
不好意思,刚才说错了 dic=E:\IDEA\workspace\父项目名称\子项目名称/src/main/resources/library/default.dic 这样写就没有问题,但是我想写成dic=library/default.dic这样,然后直接在子项目的resource中去找。不知道能不能实现这种
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
好的,明白了,多谢。有点晚了,不好意思。 |
No description provided.
The text was updated successfully, but these errors were encountered: