【发布时间】:2019-05-04 16:19:30
【问题描述】:
我正在使用 Python 和 Keras 开发 POS 标记器。我得到的数据是使用 STTS 标签,但我应该为通用标签集创建一个标签器。所以我需要翻译这个。
首先我想制作一个字典并简单地搜索替换标签,但后来我看到了使用 TaggedCorpusReader 设置标签集的选项。 (例如“棕色”)
但我错过了可以在那里使用的可能的标签集列表。我可以以某种方式使用 STTS 标记集还是必须自己制作字典?
示例来源: 代码#3:将语料库标签映射到通用标签集 https://www.geeksforgeeks.org/nlp-customization-using-tagged-corpus-reader/
corpus = TaggedCorpusReader(filePath, "standard_pos_tagged.txt", tagset='STTS') #?? doesn't work sadly
# ....
trainingCorpus.tagged_sents(tagset='universal')[1]
最后看起来像这样:(非常感谢alexis)
with open(resultFileName, "w") as output:
for sent in stts_corpus.tagged_sents():
for word, tag in sent:
try:
newTag = mapping_dict[tag];
output.write(word+"/"+newTag+" ")
except:
print("except " + str(word) + " - " + str(tag))
output.write("\n")
【问题讨论】:
标签: python keras nlp nltk pos-tagger