一步一步使用OpenNlp训练自己的不同语言的chunker模型,并获得预测序列的概率分数

时间:2015-03-27 06:16:45

标签: java model nlp opennlp maxent

我确实浏览了下面链接的文档。但事情仍然不清楚,我应该如何进行?我遵循了正确的输入训练格式,但得到如下错误。

cmd命令:

./opennlp ChunkerTrainerME -model hn-chunker.bin -lang hn -data sampletrain.txt -encoding UTF-8

错误:

Skipping corrupt line: इसके PRP NP
Skipping corrupt line: साथ  NST NP
Skipping corrupt line: ही   RP  NP
Skipping corrupt line: पार्टी   NN  NP2
Skipping corrupt line: ने   PSP NP2
Skipping corrupt line: सरकार    NN  NP3
Skipping corrupt line: से   PSP NP3
Skipping corrupt line: इस   DEM NP4
Skipping corrupt line: मसले NN  NP4
Skipping corrupt line: पर   PSP NP4
Skipping corrupt line: बयान NN  NP5
Skipping corrupt line: देने VM  VGNN
Skipping corrupt line: की   PSP VGNN
Skipping corrupt line: मांग NN  NP6
Skipping corrupt line: की   VM  VGF
Skipping corrupt line: है   VAUX    VGF

done. 0 events
Indexing...  done.
Sorting and merging events... Done indexing.
Incorporating indexed data for training...  
Exception in thread "main" java.lang.NullPointerException

at opennlp.maxent.GISTrainer.trainModel(GISTrainer.java:263)
at opennlp.maxent.GIS.trainModel(GIS.java:256)
at opennlp.model.TrainUtil.train(TrainUtil.java:184)
at opennlp.tools.chunker.ChunkerME.train(ChunkerME.java:214)
at opennlp.tools.cmdline.chunker.ChunkerTrainerTool.run(ChunkerTrainerTool.java:68)
at opennlp.tools.cmdline.CLI.main(CLI.java:222)

参考:http://opennlp.apache.org/documentation/1.5.3/manual/opennlp.html#tools.chunker

1 个答案:

答案 0 :(得分:0)

我不确定您是否还在寻找答案,但我发现问题出现在您的培训文本文件中,只需要在单词和标签之间的空格处。标签之间可能有多个空格。

例如:跳过腐败线:पार्टीNN NP2

  1. पार्टी与NN之间有3个空格。
  2. 有3个空格 在NN和NP2之间。