【发布时间】:2017-05-02 21:38:24
【问题描述】:
我有一个列表,其中包含我要进行词形还原的字符串。虽然我可以对所有字符串进行词形还原,但我很难以与输入到词形还原器的列表格式相同的列表格式返回词形化字符串。
对每个输出做一个类型,我得到一个 unicode 和 str 对象。我尝试将 unicode 转换为字符串并尝试将字符串连接到列表但没有运气。
下面是可重现的代码:
typea = ['colors', 'caresses', 'ponies', 'presumably', 'owed', 'says']
for i in xrange(0,len(typea)):
# Lemmatize the words
lemmatized_words = lmtzr.lemmatize(typea[i])
print lemmatized_words
#Output obtained:
color
caress
pony
presumably
owed
say
#Desired output
#['color', 'caress', 'pony', 'presumably', 'owed', 'say']
【问题讨论】:
标签: python lemmatization