【问题标题】:How to train custom model opeennlp?如何训练自定义模型 opennlp?
【发布时间】:2013-11-15 01:23:44
【问题描述】:

我想训练自己的自定义模型。 我可以从哪里开始?

我正在使用这个样本数据来训练一个模型:

<START:meaningless>Took connection and<END>  selected the Text in the Letter Template and cleared the Formatting of Text to Normal.

基本上我想从给定的输入中识别出一些无意义的文本。

我尝试使用 opennlp 开发文档中给出的示例代码 但出现错误:型号与名称查找器不兼容!

    Charset charset = Charset.forName("UTF-8");
ObjectStream<String> lineStream =
        new PlainTextByLineStream(new FileInputStream("mynewmodel.train"), charset);
ObjectStream<NameSample> sampleStream = new NameSampleDataStream(lineStream);

TokenNameFinderModel model;

try {
  model = NameFinderME.train("en", "meaningless", sampleStream,
      Collections.<String, Object>emptyMap(), 100, 5);
}
finally {
  sampleStream.close();
}

try {
  modelOut = new BufferedOutputStream(new FileOutputStream(modelFile));
  model.serialize(modelOut);
} finally {
  if (modelOut != null) 
     modelOut.close();      
}

【问题讨论】:

  • 一个问题“mynewmodel.train”是什么样的文件??

标签: nlp opennlp


【解决方案1】:

可能的问题:您没有向培训师提供明确标记的文本。如果我正确理解文档,PlainTextByLineStream 需要空格分隔的标记。所以

<START:meaningless> Took connection and <END>

而不是

<START:meaningless>Took connection and<END>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 2021-01-12
    • 2017-06-21
    • 1970-01-01
    相关资源
    最近更新 更多