如何在spaCy中获取POS,标签和Dep的完整列表?

时间:2019-10-03 09:10:13

标签: nlp spacy

spaCy中使用的POS,TAG和DEP值是NLP的常用值,但我相信根据语料库有一些差异。

例如,Universal Dependencies Contributors列出了37个语法依赖项。 spaCy是否使用所有这37个依赖项?仅此而已?

spaCy是否可以提供一条命令来输出所有POS,TAG和DEP值?

4 个答案:

答案 0 :(得分:4)

这是一个老问题,但也许有人觉得我的回答有帮助。我不知道是否可以输出所有 POS,但可以在此处轻松找到它们:Part-of-Speech tagging

获取 DEP 列表:

nlp = spacy.load("en_core_web_sm")
for label in nlp.get_pipe("parser").labels:
    print(label, " -- ", spacy.explain(label))

获取标签列表:

nlp = spacy.load("en_core_web_sm")
for label in nlp.get_pipe("tagger").labels:
    print(label, " -- ", spacy.explain(label))

spaCy 提供的管道在这里:Pipelines

答案 1 :(得分:2)

特定的管道组件可以显示其标签:

nlp = spacy.load('en')
nlp.get_pipe("tagger").labels
# ('$', "''", ',', '-LRB-', '-RRB-', '.', ':', 'ADD', 'AFX', 'CC', 'CD', 'DT', 'EX', 'FW', 'HYPH', 'IN', 'JJ', 'JJR', 'JJS', 'LS', 'MD', 'NFP', 'NN', 'NNP', 'NNPS', 'NNS', 'PDT', 'POS', 'PRP', 'PRP$', 'RB', 'RBR', 'RBS', 'RP', 'SYM', 'TO', 'UH', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT', 'WP', 'WP$', 'WRB', 'XX', '_SP', '``')

spacy.explain(label)将为大多数标签提供简短的定义,例如:

spacy.explain("NN")
# 'noun, singular or mass'
spacy.explain("PERSON")
# 'People, including fictional'

详细文档在这里:https://spacy.io/api/annotation

答案 2 :(得分:1)

答案 3 :(得分:1)

TAG_LIST = [".",",","-LRB-","-RRB-","``","\"\"","''",",","$","#","AFX","CC","CD","DT","EX","FW","HYPH","IN","JJ","JJR","JJS","LS","MD","NIL","NN","NNP","NNPS","NNS","PDT","POS","PRP","PRP$","RB","RBR","RBS","RP","SP","SYM","TO","UH","VB","VBD","VBG","VBN","VBP","VBZ","WDT","WP","WP$","WRB","ADD","NFP","GW","XX","BES","HVS","_SP"]
POS_LIST = ["ADJ", "ADP", "ADV", "AUX", "CONJ", "CCONJ", "DET", "INTJ", "NOUN", "NUM", "PART", "PRON", "PROPN", "PUNCT", "SCONJ", "SYM", "VERB", "X", "SPACE"]
DEP_LIST = ["acl", "acomp", "advcl", "advmod", "agent", "amod", "appos", "attr", "aux", "auxpass", "case", "cc", "ccomp", "compound", "conj", "cop", "csubj", "csubjpass", "dative", "dep", "det", "dobj", "expl", "intj", "mark", "meta", "neg", "nn", "npmod", "nsubj", "nsubjpass", "oprd", "obj", "obl", "pcomp", "pobj", "poss", "preconj", "prep", "prt", "punct",  "quantmod", "relcl", "root", "xcomp"]
NER_LIST = ["PERSON", "NORP", "FAC", "ORG", "GPE", "LOC", "PRODUCT", "EVENT", "WORK_OF_ART", "LAW", "LANGUAGE", "DATE", "TIME", "PERCENT", "MONEY", "QUANTITY", "ORDINAL", "CARDINAL"]