Spacy:我应该在单句话上训练模型还是在两个句子结合时通过?

时间:2019-09-23 11:23:55

标签: nlp feature-extraction

我的数据库中有多个句子,如下所示:

  

KP Snacks Ltd召回了McCoy的4种变体的某些日期代码   多袋薯片。 KP Snacks Ltd进行了预防性召回   以下列出的产品中,这些包装的数量很少   薯片可能包含小块塑料。

我应该先拆分句子还是将整个数据(2个句子)放入模型?

TRAIN_DATA_1 = [
    ("KP Snacks Ltd recalls certain date codes of 4 variants of McCoy’s multi bag crisps. KP Snacks Ltd has undertaken a precautionary recall of the products listed below as a very small number of these bags of crisps may contain small pieces of plastic.", {"entities": []}),
    ("I like London and Berlin.", {"entities": []}),
]

TRAIN_DATA_2 = [
    ("KP Snacks Ltd recalls certain date codes of 4 variants of McCoy’s multi bag crisps.", {"entities": []}),
("KP Snacks Ltd has undertaken a precautionary recall of the products listed below as a very small number of these bags of crisps may contain small pieces of plastic.", {"entities": []}),
    ("I like London and Berlin.", {"entities": []}),
]

简而言之,TRAIN_DATA_1与TRAIN_DATA_2正确,为什么?

1 个答案:

答案 0 :(得分:2)

  

我应该先拆分句子还是将整个数据(2个句子)放入模型?

这取决于。一切都与您的目的有关。

您似乎正在训练NER 。在这种情况下,最好使用多个较短的词组,因为NER依赖于周围的词来进行实体预测-因此,如果您提供的文本太大,则解析器会忽略其中的一部分(取决于工具),否则会影响结果(负面)。

  

简而言之,TRAIN_DATA_1与TRAIN_DATA_2正确,为什么?

没有“正确”的答案。如前所述,这取决于工具和目的。 我建议拆分,因为您将能够产生更多的数据样本以进行更好的训练。

共指解析的情况例外,因为第二个拆分短语的某些部分可能引用第一个。但是我认为这是一种罕见的情况。

在情感分析和其他最终任务中也可能出现这种情况,其中您有多个时期与一个已被分类的语句相关,并且在不丢失信息/感觉的情况下无法被打破。