1
TRAIN_DATA = [
    ("XYZxyzg hat die beste Camera für Selfies", {"entities": [(0, 7, "BRAND"), (23, 28, "CAMERA")]}),
]

在训练这一点后,我一直在这条线上收到一个错误:

serWarning: [W030] Some entities could not be aligned in the text "XYZxyzg hat die beste Camera für Selfie" with entities "[(0, 7, 'BRAND'), (23, 28, 'CAMERA')]". Use `spacy.gold.biluo_tags_from_offsets(nlp.make_doc(text), entities)` to check the alignment. Misaligned entities ('-') will be ignored during training.
  gold = GoldParse(doc, **gold)

我的索引有什么问题?我应该排除空格吗?我也试过了,但它似乎不起作用。如警告所示,我如何使用它spacy.gold.biluo_tags_from_offsets(nlp.make_doc(text), entities)来检查索引?

4

1 回答 1

2

从你的帖子:

TRAIN_DATA = [
    ("XYZxyzg hat die beste Camera für Selfies", {"entities": [(0, 7, "BRAND"), (23, 28, "CAMERA")]}),
]

实体偏移量需要与令牌边界对齐。您不能在令牌中间开始/结束实体。在您的情况下,它看起来像是一个小错误,我认为第二个实体的偏移量应该是(22, 28, "CAMERA")

于 2020-11-17T13:58:33.290 回答