【发布时间】:2018-08-26 18:14:42
【问题描述】:
无法弄清楚如何对 txt 文件中的单词进行词形还原。我已经列出了这些词,但我不知道事后如何对它们进行词形还原。
这是我所拥有的:
import nltk, re
nltk.download('wordnet')
from nltk.stem.wordnet import WordNetLemmatizer
def lemfile():
f = open('1865-Lincoln.txt', 'r')
text = f.read().lower()
f.close()
text = re.sub('[^a-z\ \']+', " ", text)
words = list(text.split())
【问题讨论】:
-
请注意“词干化和词形还原”部分。
标签: python nltk lemmatization