'Transform a sequence of documents to a document-term matrix.
Parameters
X : iterable over raw text documents, length = n_samples
Samples. Each sample must be a text document (either bytes or
unicode strings, file name or file object depending on the
constructor argument) which will be tokenized and hashed.
Returns
X : scipy.sparse matrix, shape = (n_samples, self.n_features)
Document-term matrix.'

def transform(self, X):

    if isinstance(X, six.string_types):
        raise ValueError(u'Iterable    over    raw    text    documents    expected,    string    object    received.')
    analyzer = self.build_analyzer()
    X = self._get_hasher().transform((analyzer(doc) for doc in X))
    if self.binary:
        X.data.fill(1)
    if (self.norm is not None):
        X = normalize(X, norm=self.norm, copy=False)
    return X
