spacy训练数据中的头是什么意思?

问题描述 投票:0回答:1

我正在尝试根据自己的数据训练模型,并且正在使用Spacy库。

但是我对代码示例中的“ #token head index”感到困惑。

在这里究竟是什么意思?

# training data: texts, heads and dependency labels
# for no relation, we simply chose an arbitrary dependency label, e.g. '-'
TRAIN_DATA = [
    (
        "find a cafe with great wifi",
        {
            "heads": [0, 2, 0, 5, 5, 2],  # index of token head
            "deps": ["ROOT", "-", "PLACE", "-", "QUALITY", "ATTRIBUTE"],
        },
    )
python json nlp nltk spacy
1个回答
0
投票

在您的示例中,任务是重建tree of syntactic dependencies。这棵树为每个单词显示了其附加到的相应“头”单词以及附件的类型。描述这种树的一种特定格式称为CoNLL-U

在您的示例中,例如“ wifi”(单词5)附加了“ great”(单词4,如果从0算起),并且“ great”是“ wifi”的quality。因此,heads的第4个条目等于5,deps的第4个条目等于“ QUALITY”。

© www.soinside.com 2019 - 2024. All rights reserved.