|
29 | 29 | from ..preprocessing import normalize |
30 | 30 | from .hashing import FeatureHasher |
31 | 31 | from .stop_words import ENGLISH_STOP_WORDS |
32 | | -from sklearn.externals import six |
| 32 | +from ..utils import deprecated |
| 33 | +from ..externals import six |
33 | 34 |
|
34 | 35 | __all__ = ['CountVectorizer', |
35 | 36 | 'ENGLISH_STOP_WORDS', |
@@ -257,10 +258,16 @@ def _check_vocabulary(self): |
257 | 258 | raise ValueError(msg) |
258 | 259 | if not vocabulary: |
259 | 260 | raise ValueError("empty vocabulary passed to fit") |
260 | | - self.fixed_vocabulary = True |
| 261 | + self.fixed_vocabulary_ = True |
261 | 262 | self.vocabulary_ = dict(vocabulary) |
262 | 263 | else: |
263 | | - self.fixed_vocabulary = False |
| 264 | + self.fixed_vocabulary_ = False |
| 265 | + |
| 266 | + @property |
| 267 | + @deprecated("The `fixed_vocabulary` attribute is deprecated and will be " |
| 268 | + "removed in 0.18. Please use `fixed_vocabulary_` instead.") |
| 269 | + def fixed_vocabulary(self): |
| 270 | + return self.fixed_vocabulary_ |
264 | 271 |
|
265 | 272 |
|
266 | 273 | class HashingVectorizer(BaseEstimator, VectorizerMixin): |
@@ -810,12 +817,13 @@ def fit_transform(self, raw_documents, y=None): |
810 | 817 | min_df = self.min_df |
811 | 818 | max_features = self.max_features |
812 | 819 |
|
813 | | - vocabulary, X = self._count_vocab(raw_documents, self.fixed_vocabulary) |
| 820 | + vocabulary, X = self._count_vocab(raw_documents, |
| 821 | + self.fixed_vocabulary_) |
814 | 822 |
|
815 | 823 | if self.binary: |
816 | 824 | X.data.fill(1) |
817 | 825 |
|
818 | | - if not self.fixed_vocabulary: |
| 826 | + if not self.fixed_vocabulary_: |
819 | 827 | X = self._sort_features(X, vocabulary) |
820 | 828 |
|
821 | 829 | n_doc = X.shape[0] |
|
0 commit comments