当前位置: 首页 > 知识库问答 >
问题:

训练数据opennlp分类器中应该有多少行和文档

奚光霁
2023-03-14

我遵循Apache open-nlp的留档。我能够理解句子检测、标记器、名称查找器。但是我被分类器卡住了。原因是,我不明白,如何创建分类模型。

我确实明白我需要创建一个文件。格式非常清楚,它需要是一个类别空间和一个单行文档。以. train扩展名保存文件。

所以我创建了以下文件:

Refund What is the refund status for my order #342 ?
NewOffers Are there any new offers for your products ?

我给这个命令-

Opennlp DoccatTrainer模型en-doccat.binlang en数据en-doccat.train编码UTF-8

它开始做某事,然后返回一个错误。以下是命令提示符中的内容:

Indexing events using cutoff of 5

    Computing event counts...  done. 2 events
    Indexing...  Dropped event Refund:[bow=What, bow=is, bow=the, bow=refund, bow=status, bow=for, bow=my, bow=order, bow=#342, bow=?]
Dropped event NewOffers:[bow=Are, bow=there, bow=any, bow=new, bow=offers, bow=for, bow=your, bow=products, bow=?]
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.doccat.DocumentCategorizerME.train(DocumentCategorizerME.java:162)
    at opennlp.tools.cmdline.doccat.DoccatTrainerTool.run(DoccatTrainerTool.java:61)
    at opennlp.tools.cmdline.CLI.main(CLI.java:222)

我只是不明白为什么这里会出现空指针异常?我还试图增加两行,但没有结果。

Refund What is the refund status for my order #342 ?
NewOffers Are there any new offers for your products ?
Refund Can I place a refund request for electronics ?
NewOffers Is there any new offer on buying worth 5000 ?  

我找到了这个博客,但这里也做了几乎相同的事情。在尝试他的训练文件时,它很有魅力。我的文件中有什么问题?我如何解决错误。

当我尝试opennlp doccatrainer时,它会为我打开帮助,所以路径不是问题。感谢您的帮助。

编辑:我把文件改成了

Refund What is the refund status for my order #342 ? Can I place a refund request for clothes ?
NewOffers Are there any new offers for your products ? what are the offers on new products or new offers on old products?
Refund Can I place a refund request for electronics ?
NewOffers Is there any new offer on buying worth 5000 ? 

它是有效的,我认为它与文档有关(显然应该是两句话),并删除了最后两行。

使它

Refund What is the refund status for my order #342 ? Can I place a refund request for clothes ?
NewOffers Are there any new offers for your products ? what are the offers on new products or new offers on old products? 

但它又一次失败了,现在的问题是它需要什么样的数据/格式/文档?

谢谢

共有2个答案

微生令雪
2023-03-14

可以在DoccatTrainer命令中使用-cutoff标志来更改默认值。在您的情况下,您可以添加-cutoff 1,将每个类别的最小文档数设置为1。

宁欣怿
2023-03-14

您必须从每个类别中添加超过5个样本。因为默认截止标记大小为5,

请参考这篇博文http://madhawagunasekara.blogspot.com/2014/11/nlp-categorizer.html

 类似资料:
  • 我试图用下面的代码训练模型,但我一直在方法上收到错误,它告诉我将更改为。为什么?

  • 我正在尝试使用OpenNLP对发票进行分类。根据它的描述,我将它分为两类。我已经建立了一个包含20K描述的培训文件,并将每个描述标记到正确的类中。 培训数据如下所示(第一列是代码,我将其用作类,第二列是发票描述): 使用OpenNLP的Document分类器,我实现了98.5%的正确率。但是,为了提高效率,我取了错误的分类文档并用它来扩展训练数据。 例如,当我第一次运行它时,“MOTONETA I

  • 译者:bat67 最新版会在译者仓库首先同步。 目前为止,我们以及看到了如何定义网络,计算损失,并更新网络的权重。 现在可能会想, 数据呢? 通常来说,当必须处理图像、文本、音频或视频数据时,可以使用python标准库将数据加载到numpy数组里。然后将这个数组转化成torch.*Tensor。 对于图片,有Pillow,OpenCV等包可以使用 对于音频,有scipy和librosa等包可以使用

  • OpenNLP的性能明显低于我测试过的其他文档分类器,所以在我放弃它之前,我决定确保我在玩所有的刻度盘和旋钮。对我来说最突出的一件事是OpenNLP,它可以非常快地训练我的模型(大约1.2秒)。我使用过的其他NLP工具可能需要几分钟甚至几个小时的训练。我的培训档案中有大约12k条记录。 我试图将迭代次数从10次增加到10000次,不幸的是,它似乎对训练时间或准确性没有任何影响。 奇怪的是OpenN

  • 我有文件及其非常大的文件说100MB文件。我想执行NER以提取组织名称。我使用OpenNLP进行了培训。 示例代码: 但是我得到了一个错误:。 有没有办法使用openNLP for NER来训练大型数据集?你能发布示例代码吗? 当我谷歌时,我发现Class GIS和DataIndexer界面可用于训练大型数据集,但我知道如何训练?你能发布示例代码吗?

  • 我正在使用OpenNLP进行数据分类。我在这里找不到疾病的TokenNameFindModel。我知道我可以创建自己的模型,但我想知道是否有针对疾病的大样本训练数据?