Dependency parsing 如何将文本句子转换为CoNLL-U格式?
我正在研究使用CoNLL-U格式的依赖项解析。 我可以找到如何处理CoNLL-U解析器或令牌列表,但找不到如何将文本语句转换为CoNLL-U格式 我试着从中转换代码 “test”文件是conllconverter(path)函数的输入,是“\U io Text10Wrapper”格式文件,其中包含我要转换为CoNLL-U文件的文本句子,例如: 1.完全令人沮丧的经历。 2.支付额外的钱,以获得空调连接 但是,在我尝试了上面定义的conllConverter(path)函数之后,输出只显示了10个原始列(看起来像CoNLL-U格式)和原始文本,没有任何额外的信息 最后,我想问一下如何将文本句子转换成CoNLL-U格式。试试这个Dependency parsing 如何将文本句子转换为CoNLL-U格式?,dependency-parsing,conll,Dependency Parsing,Conll,我正在研究使用CoNLL-U格式的依赖项解析。 我可以找到如何处理CoNLL-U解析器或令牌列表,但找不到如何将文本语句转换为CoNLL-U格式 我试着从中转换代码 “test”文件是conllconverter(path)函数的输入,是“\U io Text10Wrapper”格式文件,其中包含我要转换为CoNLL-U文件的文本句子,例如: 1.完全令人沮丧的经历。 2.支付额外的钱,以获得空调连接 但是,在我尝试了上面定义的conllConverter(path)函数之后,输出只显示了10个
import spacy
from spacy_conll import ConllFormatter
nlp = spacy.load('en_core_web_sm')
conllformatter = ConllFormatter(nlp, ext_names={'conll_pd': 'pandas'},
conversion_maps={'lemma': {'-PRON-': 'PRON'}})
nlp.add_pipe(conllformatter, after='parser')
doc = nlp('The quick brown fox jumps over the lazy dog.')
print(doc._.pandas)
这将为您提供以下输出
id form lemma upostag xpostag feats head deprel deps misc
1 The the DET DT _ 5 det _ _
2 quick quick ADJ JJ Degree=pos 5 amod _ _
3 brown brown ADJ JJ Degree=pos 5 amod _ _
4 fox fox NOUN NN Number=sing 5 compound _ _
5 jumps jump NOUN NNS Number=plur 0 ROOT _ _
6 over over ADP IN _ 5 prep _ _
7 the the DET DT _ 9 det _ _
8 lazy lazy ADJ JJ Degree=pos 9 amod _ _
9 dog dog NOUN NN Number=sing 6 pobj _ SpaceAfter=No
10 . . PUNCT . PunctType=peri 5 punct _ SpaceAfter=No
id form lemma upostag xpostag feats head deprel deps misc
1 The the DET DT _ 5 det _ _
2 quick quick ADJ JJ Degree=pos 5 amod _ _
3 brown brown ADJ JJ Degree=pos 5 amod _ _
4 fox fox NOUN NN Number=sing 5 compound _ _
5 jumps jump NOUN NNS Number=plur 0 ROOT _ _
6 over over ADP IN _ 5 prep _ _
7 the the DET DT _ 9 det _ _
8 lazy lazy ADJ JJ Degree=pos 9 amod _ _
9 dog dog NOUN NN Number=sing 6 pobj _ SpaceAfter=No
10 . . PUNCT . PunctType=peri 5 punct _ SpaceAfter=No