我有一个文本文件.我需要一个句子列表.
如何实施?有许多细微之处,例如在缩写中使用点.
我的旧正则表达式很糟糕.
re.compile('(\. |^|!|\?)([A-Z][^;?\.<>@\^&/\[\]]*(\.|!|\?) )',re.M)
Run Code Online (Sandbox Code Playgroud) 以下代码运行Naive Bayes电影评论分类器.该代码生成一个信息最丰富的功能列表.
注意: **movie review**文件夹在nltk.
from itertools import chain
from nltk.corpus import stopwords
from nltk.probability import FreqDist
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import movie_reviews
stop = stopwords.words('english')
documents = [([w for w in movie_reviews.words(i) if w.lower() not in stop and w.lower() not in string.punctuation], i.split('/')[0]) for i in movie_reviews.fileids()]
word_features = FreqDist(chain(*[i for i,j in documents]))
word_features = word_features.keys()[:100]
numtrain = int(len(documents) * 90 / 100)
train_set = [({i:(i in tokens) for i in …Run Code Online (Sandbox Code Playgroud) 有人能告诉我NLTK中语料库,语料库和词典之间的区别吗?
什么是电影数据集?
什么是Wordnet?
我有一些大事,让我们说:[('word','word'),('word','word'),...,('word','word')].我如何使用scikit HashingVectorizer创建一个特征向量,随后将呈现给某些分类算法,例如SVC或Naive Bayes或任何类型的分类算法?
nlp ×3
nltk ×2
python ×2
corpus ×1
lexical ×1
python-2.7 ×1
scikit-learn ×1
scipy ×1
split ×1
text ×1