是否可以加快Wordnet Lemmatizer的速度? [英] Is it possible to speed up Wordnet Lemmatizer?

查看:113
本文介绍了是否可以加快Wordnet Lemmatizer的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过布朗语料库上的NLTK使用Wordnet Lemmatizer(以确定其中的名词是否以单数形式或复数形式使用.)
from nltk.stem.wordnet import WordNetLemmatizer
l = WordnetLemmatizer()

I'm using the Wordnet Lemmatizer via NLTK on the Brown Corpus (to determine if the nouns in it are used more in their singular form or their plural form).
i.e. from nltk.stem.wordnet import WordNetLemmatizer
l = WordnetLemmatizer()

我已经注意到,即使是最简单的查询(例如下面的查询)也要花费很长时间(至少需要一两秒钟).
l("cats")

I've noticed that even the simplest queries such as the one below takes quite a long time (at least a second or two).
l("cats")

大概是因为每个查询都必须与Wordnet建立Web连接?..
我想知道是否仍然可以使用Wordnet Lemmatizer,但执行速度要快得多吗?例如,将Wordnet下载到我的机器上对我有帮助吗? 或其他建议?

Presumably this is because a web connection must be made to Wordnet for each query?..
I'm wondering if there is a way to still use the Wordnet Lemmatizer but have it perform much faster? For instance, would it help at all for me to download Wordnet on to my machine? Or any other suggestions?

我试图找出是否可以使Wordnet Lemmatizer更快,而不是尝试使用其他lemmatizer,因为我发现它在诸如Porter和Lancaster之类的系统中效果最好.

I'm trying to figure out if the Wordnet Lemmatizer can be made faster rather than trying a different lemmatizer, because I've found it works the best among others like Porter and Lancaster.

推荐答案

我使用了这样的lemmatizer

I've used the lemmatizer like this

    from nltk.stem.wordnet import WordNetLemmatizer #To download corpora: python -m    nltk.downloader all
    lmtzr=WordNetLemmatizer()#create a lemmatizer object
    lemma = lmtzr.lemmatize('cats')

在我的机器上一点也不慢.无需连接到网络即可.

It is not slow at all on my machine. There is no need to connect to the web to do this.

这篇关于是否可以加快Wordnet Lemmatizer的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆