我有两个来自词性标注器的列表,如下所示:
pos_tags = [('This', u'DT'), ('is', u'VBZ'), ('a', u'DT'), ('test', u'NN'), ('sentence', u'NN'), ('.', u'.'), ('My', u"''"), ('name', u'NN'), ('is', u'VBZ'), ('John', u'NNP'), ('Murphy', u'NNP'), ('and', u'CC'), ('I', u'PRP'), ('live', u'VBP'), ('happily', u'RB'), ('on', u'IN'), ('Planet', u'JJ'), ('Earth', u'JJ'), ('!', u'.')]
pos_names = [('John', 'NNP'), ('Murphy', 'NNP')]
我想创建一个最终列表,它使用 pos_names 中的列表项更新 pos_tags。所以基本上我需要在 pos_tags 中找到 John 和 Murphy,并将 POS 标签替换为 NNP。