将 [spacy list of pos_] 转换为 [list of tag_]

问题描述

['VERB','NOUN','ADP','CCONJ','PUNCT']


#how to convert this list to this :


['VBG','NNS','IN','CC','NN','.']

** 我已经使用 spacy pos_ 编写了代码,但现在我的输入已更改为 tag_ **

解决方法

data = ['VERB','NOUN','ADP','CCONJ','PUNCT']
lookup = {
        'ADP': 'IN','CCONJ': 'CC','NOUN': 'NNS','NOUN': 'NN','PUNCT': '.','VERB': 'VBG'
}

result = [ lookup[w] for w in data ]

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...