首页 > 解决方案 > 将 [spacy list of pos_] 转换为 [list of tag_ ]

问题描述

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


#how to convert this list to this :


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

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

标签: pythonpython-3.xspacytaggingpos-tagger

解决方案


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

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

推荐阅读