小编Shi*_*ngh的帖子

Python中更快的缩编技术

我试图找到一种使用NLTK Word Net Lemmatizer 对列表中的单词(命名为text)进行词素化的更快方法。显然,这是我整个程序中最耗时的步骤(使用cProfiler查找相同的步骤)。

以下是我正在尝试优化速度的一段代码-

def lemmed(text):
    l = len(text)
    i = 0
    wnl = WordNetLemmatizer()
    while (i<l):
        text[i] = wnl.lemmatize(text[i])
        i = i + 1
    return text
Run Code Online (Sandbox Code Playgroud)

使用lemmatizer会使我的性能降低20倍。任何帮助,将不胜感激。

python performance nltk lemmatization python-3.x

5
推荐指数
1
解决办法
1968
查看次数

标签 统计

lemmatization ×1

nltk ×1

performance ×1

python ×1

python-3.x ×1