Last active
August 29, 2015 14:26
-
-
Save espeed/ec085a79542b51b5d89a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import pickle | |
import nltk.data | |
from nltk.util import ngrams | |
t0 = timeit.default_timer() | |
fin = open("C:/Users/ned/Desktop/gherkin.pickle","rb") | |
classifier = pickle.load(fin) | |
t1 = timeit.default_timer() | |
load_time = t1-t0 | |
print "LOAD TIME: ", load_time | |
words = ['boring', 'and', 'stupid', 'movie'] | |
ngram_list = words + list(ngrams(words, 2)) + list(ngrams(words, 3)) | |
feats = dict([(word, True) for word in ngram_list]) | |
t0 = timeit.default_timer() | |
result = classifier.classify(feats) | |
t1 = timeit.default_timer() | |
classify_time = t1-t0 | |
print "CLASSIFY TIME: ", classify_time | |
print "RESULT: ", result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
from nltk.util import ngrams | |
fin = open("C:/Users/ned/Desktop/gherkin.pickle","rb") | |
classifier = pickle.load(fin) | |
words = ['boring', 'and', 'stupid', 'movie'] | |
ngram_list = words + list(ngrams(words, 2)) + list(ngrams(words, 3)) | |
feats = dict([(word, True) for word in ngram_list]) | |
dist = classifier.prob_classify(feats) | |
#for sample in dist.samples(): | |
# print("%s probability: %f" % (sample, dist.prob(sample))) | |
sample = "pos" | |
print("%s probability: %f" % (sample, dist.prob(sample))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment