from pattern.vector import Document, NB
from pattern.db import csv
nb = NB()
for review, rating in csv('reviews.csv'):
    v = Document(review, type=int(rating), stopwords=True)
nb.train(v)
print(nb.classes)
print(nb.classify(Document('A good movie!')))
Python - A way to learn and detect text patterns?