Merge pull request #629 from kylepjohnson/master

Fix attribute error in nn_text_class.py, add module docstring
This commit is contained in:
Matthew Honnibal 2016-11-14 05:26:56 +11:00 committed by GitHub
commit 901a96f7cd

View File

@ -1,3 +1,11 @@
"""This script expects something like a binary sentiment data set, such as
that available here: `http://www.cs.cornell.edu/people/pabo/movie-review-data/`
It expects a directory structure like: `data_dir/train/{pos|neg}`
and `data_dir/test/{pos|neg}`. Put (say) 90% of the files in the former
and the remainder in the latter.
"""
from __future__ import unicode_literals from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
@ -56,7 +64,7 @@ class Extractor(object):
self.vector.fill(0) self.vector.fill(0)
n = 0 n = 0
for orth_id, freq in bow.items(): for orth_id, freq in bow.items():
self.vector += self.nlp.vocab[self.nlp.vocab.strings[orth_id]].repvec * freq self.vector += self.nlp.vocab[self.nlp.vocab.strings[orth_id]].vector * freq
# Apply the fine-tuning we've learned # Apply the fine-tuning we've learned
if orth_id < E.shape[0]: if orth_id < E.shape[0]:
self.vector += E[orth_id] * freq self.vector += E[orth_id] * freq