【发布时间】: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”是什么样的文件??