gpt4 book ai didi

python - 获取扩展的 spaCy 形态信息

转载 作者:太空宇宙 更新时间:2023-11-04 04:24:04 26 4
gpt4 key购买 nike

我希望将 spaCy 用于我的研究,而形态学信息对我来说很重要。

阅读 the documentation on rule-based morphology ,我不知道如何将标签(例如 NNP、VBZ)转换为词法向量(例如 VerbForm=Fin、Mood=Ind、Tense=Pres)。是否有内置的 tag map可用的?像这样的东西(内置)会很有用,但我似乎找不到它:

{
"NNS": {POS: NOUN, "Number": "plur"},
"VBG": {POS: VERB, "VerbForm": "part", "Tense": "pres", "Aspect": "prog"},
"DT": {POS: DET}
...
}

我找到了 the PoS Tagging table ,但我无法确定此映射是否在代码中可用,甚至无法直接在解析的 token 中使用?


我找到了 the tagmap for English在 GitHub 上,但我不确定如何导入它。有帮助吗?

最佳答案

根据对 language class 的进一步调查,我发现你可以通过使用获取默认标签映射

> nlp = spacy.load('en')
> print(nlp.Defaults.tag_map)
{'.': {74: 96, 'PunctType': 'peri'}, ',': {74: 96, 'PunctType': 'comm'}, '-LRB-': {74: 96, 'PunctType': 'brck', 'PunctSide': 'ini'}, '-RRB-': {74: 96, 'PunctType': 'brck', 'PunctSide': 'fin'}, '``': {74: 96, 'PunctType': 'quot', 'PunctSide': 'ini'}, '""': {74: 96, 'PunctType': 'quot', 'PunctSide': 'fin'}, "''": {74: 96, 'PunctType': 'quot', 'PunctSide': 'fin'}, ':': {74: 96}, '$': {74: 98, 'Other': {'SymType': 'currency'}}, '#': {74: 98, 'Other': {'SymType': 'numbersign'}}, 'AFX': {74: 83, 'Hyph': 'yes'}, 'CC': {74: 88, 'ConjType': 'coor'}, 'CD': {74: 92, 'NumType': 'card'}, 'DT': {74: 89}, 'EX': {74: 85, 'AdvType': 'ex'}, 'FW': {74: 100, 'Foreign': 'yes'}, 'HYPH': {74: 96, 'PunctType': 'dash'}, 'IN': {74: 84}, 'JJ': {74: 83, 'Degree': 'pos'}, 'JJR': {74: 83, 'Degree': 'comp'}, 'JJS': {74: 83, 'Degree': 'sup'}, 'LS': {74: 96, 'NumType': 'ord'}, 'MD': {74: 99, 'VerbType': 'mod'}, 'NIL': {74: ''}, 'NN': {74: 91, 'Number': 'sing'}, 'NNP': {74: 95, 'NounType': 'prop', 'Number': 'sing'}, 'NNPS': {74: 95, 'NounType': 'prop', 'Number': 'plur'}, 'NNS': {74: 91, 'Number': 'plur'}, 'PDT': {74: 83, 'AdjType': 'pdt', 'PronType': 'prn'}, 'POS': {74: 93, 'Poss': 'yes'}, 'PRP': {74: 94, 'PronType': 'prs'}, 'PRP$': {74: 83, 'PronType': 'prs', 'Poss': 'yes'}, 'RB': {74: 85, 'Degree': 'pos'}, 'RBR': {74: 85, 'Degree': 'comp'}, 'RBS': {74: 85, 'Degree': 'sup'}, 'RP': {74: 93}, 'SP': {74: 102}, 'SYM': {74: 98}, 'TO': {74: 93, 'PartType': 'inf', 'VerbForm': 'inf'}, 'UH': {74: 90}, 'VB': {74: 99, 'VerbForm': 'inf'}, 'VBD': {74: 99, 'VerbForm': 'fin', 'Tense': 'past'}, 'VBG': {74: 99, 'VerbForm': 'part', 'Tense': 'pres', 'Aspect': 'prog'}, 'VBN': {74: 99, 'VerbForm': 'part', 'Tense': 'past', 'Aspect': 'perf'}, 'VBP': {74: 99, 'VerbForm': 'fin', 'Tense': 'pres'}, 'VBZ': {74: 99, 'VerbForm': 'fin', 'Tense': 'pres', 'Number': 'sing', 'Person': 3}, 'WDT': {74: 83, 'PronType': 'int|rel'}, 'WP': {74: 91, 'PronType': 'int|rel'}, 'WP$': {74: 83, 'Poss': 'yes', 'PronType': 'int|rel'}, 'WRB': {74: 85, 'PronType': 'int|rel'}, 'ADD': {74: 100}, 'NFP': {74: 96}, 'GW': {74: 100}, 'XX': {74: 100}, 'BES': {74: 99}, 'HVS': {74: 99}, '_SP': {74: 102}}

关于python - 获取扩展的 spaCy 形态信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53849929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com