OpenNLP 在使用泰国模型时出错

OpenNLP gives error when using Thai model

我已尝试遵循 的建议,但出现此错误:

C:\OpenNLP_models\tool\apache-opennlp-1.5.3-bin\apache-opennlp-1.5.3\bin>opennlp TokenizerME C:\OpenNLP_models\tool\apache-opennlp-1.5.3-bin\apache-opennlp-1.5.3\bin\thai.tok.bin < test.txt

Loading Tokenizer model ... Exception in thread "main" java.lang.NullPointerException
    at opennlp.tools.util.model.BaseModel.getManifestProperty(BaseModel.java:491)
    at opennlp.tools.util.model.BaseModel.initializeFactory(BaseModel.java:245)
    at opennlp.tools.util.model.BaseModel.loadModel(BaseModel.java:237)
    at opennlp.tools.util.model.BaseModel.<init>(BaseModel.java:181)
    at opennlp.tools.tokenize.TokenizerModel.<init>(TokenizerModel.java:125)
    at opennlp.tools.cmdline.tokenizer.TokenizerModelLoader.loadModel(TokenizerModelLoader.java:39)
    at opennlp.tools.cmdline.tokenizer.TokenizerModelLoader.loadModel(TokenizerModelLoader.java:31)
    at opennlp.tools.cmdline.ModelLoader.load(ModelLoader.java:62)
    at opennlp.tools.cmdline.tokenizer.TokenizerMETool.run(TokenizerMETool.java:41)
    at opennlp.tools.cmdline.CLI.main(CLI.java:225)

test.txt 文件包含句子“ผมหิวข้าว”。

谁能告诉我如何解决它?我想使用 POSTagger。 谢谢。

我认为您缺少 manifest.properties 文件。你能解压缩 thai.tok.bin 文件并检查它是否包含这些文件:

  1. token.model(二进制分词器模型)
  2. manifest.properties(配置)

manifest.properties的内容应该是这样的,摘自你link的问题:

Manifest-Version=1.0.
Language=th
OpenNLP-Version=1.5.0
Component-Name=TokenizerME
useAlphaNumericOptimization=false