我已经开始使用 Spacy.io 的 NLP 包,并检查了一些介绍以及一些示例代码。
我对 spacy.en.English.matcher.add 方法很感兴趣——添加我自己的实体的格式是什么?虽然解释了基本格式,但似乎还有其他可用功能。我添加的实体可以链接到 dbpedia/wikipedia 条目或其他外部链接吗?
这是 Spacy 匹配器示例中的代码: https ://github.com/honnibal/spaCy/blob/master/examples/matcher_example.py
nlp.matcher.add(
"GoogleNow", # Entity ID: Not really used at the moment.
"PRODUCT", # Entity type: should be one of the types in the NER data
{"wiki_en": "Google_Now"}, # Arbitrary attributes. Currently unused.
[ # List of patterns that can be Surface Forms of the entity
# This Surface Form matches "Google Now", verbatim
[ # Each Surface Form is a list of Token Specifiers.
{ # This Token Specifier matches tokens whose orth field is "Google"
ORTH: "Google"
},
{ # This Token Specifier matches tokens whose orth field is "Now"
ORTH: "Now"
}
],
[ # This Surface Form matches "google now", verbatim, and requires
# "google" to have the NNP tag. This helps prevent the pattern from
# matching cases like "I will google now to look up the time"
{
ORTH: "google",
TAG: "NNP"
},
{
ORTH: "now"
}
]
]
)
感谢您的时间。