java - MeCab 路径参数在 Windows 上不接受空格

标签 java mecab

我已经成功使用了MeCab Java打电话Mecab从我的Java代码。 我使用以下语句来初始化标记器:

tagger = new Tagger("--node-format=%f[7]\\t --unk-format=%m\\t --eos-format=\\n --rcfile=" + filePath + "/mecabrc" + " --dicdir=" + filePath + "/ipadic");

现在我面临一个问题,filePath 实际上可能包含空白字符,例如:c:\folder name\。当我尝试使用这样的路径时,我从 Mecab 收到一条错误消息:

java.lang.RuntimeException: C:\src\c\common\mecab\src\main\c\tagger.cpp(151) [load_dictionary_resource(param)] C:\src\c\common\mecab\src\main\c\param.cpp(71) [ifs] no such file or directory: c:/folder

这意味着 Mecab 没有正确识别空格。

知道如何指示 Mecab 接受 Windows 文件路径中的空白字符吗?

最佳答案

我阅读了 MeCab 源代码,没有办法让 MeCab 在不编辑源代码和编译自定义版本的情况下接受路径中的空白。您至少有三个解决方法:

  1. 将目录重命名为不带空格的名称
  2. 尽可能使用相对路径
  3. 使用 windows 8.3 文件名

Here is a link to showing more information on how to get 8.3 filenames in java.

关于java - MeCab 路径参数在 Windows 上不接受空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10299807/

相关文章:

Java 多态性 : How can I avoid type casting input parameters?

java - ListView Activity 在微调器类内的开关盒中无法正常工作

Windows 上的 Python mecab 包导入错误 'not defined'

python - Mac 10.8.3 MeCab Python "Symbol Not found"错误

java - 使用 Tomcat 7 javax/inject/Singleton 部署 JAX-RS (Jersey 2.13) Web 服务

java - 如何定义泛型类的 JNI 方法签名?

java - 插入sql数据库android eclipse

nlp - 可以平衡 unidic 与 unidic-neologd 吗?

python - Pandas Series.apply 不能由字符串组成