相关疑难解决方法(0)

POS-Tagger非常慢

nltk用来从句子中生成n-gram,首先删除给定的停用词.但是,nltk.pos_tag()我的CPU(Intel i7)的速度极慢,最长需要0.6秒.

输出:

['The first time I went, and was completely taken by the live jazz band and atmosphere, I ordered the Lobster Cobb Salad.']
0.620481014252
["It's simply the best meal in NYC."]
0.640982151031
['You cannot go wrong at the Red Eye Grill.']
0.644664049149
Run Code Online (Sandbox Code Playgroud)

代码:

for sentence in source:

    nltk_ngrams = None

    if stop_words is not None:   
        start = time.time()
        sentence_pos = nltk.pos_tag(word_tokenize(sentence))
        print time.time() - start

        filtered_words = [word for (word, pos) in sentence_pos if …
Run Code Online (Sandbox Code Playgroud)

python nlp nltk pos-tagger

7
推荐指数
2
解决办法
2566
查看次数

标签 统计

nlp ×1

nltk ×1

pos-tagger ×1

python ×1