'Learn the vocabulary dictionary and return the count vectors
This is more efficient than calling fit followed by transform.
Parameters
raw_documents: iterable
an iterable which yields either str, unicode or file objects
Returns
vectors: array, [n_samples, n_features]'

def fit_transform(self, raw_documents, y=None):

    if self.fixed_vocabulary:
        analyze = self.build_analyzer()
        term_counts_per_doc = [PosCounter(analyze(doc), normalize=self.normalize, poscache=self.poscache) for doc in raw_documents]
        return self._term_count_dicts_to_matrix(term_counts_per_doc)
    self.vocabulary_ = {}
    term_counts_per_doc = []
    term_counts = Counter()
    analyze = self.build_analyzer()
    for doc in raw_documents:
        term_count_current = PosCounter(analyze(doc), normalize=self.normalize, poscache=self.poscache)
        term_counts.update(term_count_current)
        term_counts_per_doc.append(term_count_current)
    self.write_poscache()
    terms = set(term_counts)
    self.vocabulary_ = dict(((t, i) for (i, t) in enumerate(sorted(terms))))
    return self._term_count_dicts_to_matrix(term_counts_per_doc)
