我安装了TextBlob。
$ python -m pip install TextBlob
Requirement already satisfied: TextBlob in c:\users\marc\anaconda2\lib\site-packages
Requirement already satisfied: nltk>=3.1 in c:\users\marc\anaconda2\lib\site-packages (from TextBlob)
Requirement already satisfied: six in c:\users\marc\anaconda2\lib\site-packages (from nltk>=3.1->TextBlob)
仅在我尝试运行此代码时:
from __future__ import division, unicode_literals
import math
from textblob import TextBlob as tb
def tf(word, blob):
return blob.words.count(word) / len(blob.words)
def n_containing(word, bloblist):
return sum(1 for blob in bloblist if word in blob.words)
def idf(word, bloblist):
return math.log(len(bloblist) / (1 + n_containing(word, bloblist)))
def tfidf(word, blob, bloblist):
return tf(word, blob) * idf(word, bloblist)
我仍然收到此错误:
from textblob import TextBlob as tb
ImportError: No module named 'textblob'
对这里出了什么问题的想法?