__all__ = ['CounterHashingVectorizer', 'ListHashingVectorizer', 'ListCountVectorizer', 'SpaceTokenizerTransformer']

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import HashingVectorizer

from .base import PureTransformer


class ListNGramAnalyzer(object):
    def __init__(self, ngram_range=(1, 1), ngram_delimiter=' ', **kwargs):
        if isinstance(ngram_range, tuple) and len(ngram_range) == 2: ngrams = list(range(ngram_range[0], ngram_range[1] + 1))
        elif isinstance(ngram_range, str): ngrams = [ngram_range]
        else: ngrams = ngram_range
        ngrams.sort()

        self.ngrams = ngrams
        self.ngram_delimiter = ngram_delimiter
    #end def

    def __call__(self, L):
        L = list(L)
        length = len(L)
        ngram_delimiter = self.ngram_delimiter

        for i in range(length):
            for n in self.ngrams:
                if i + n > length: break

                yield ngram_delimiter.join(L[i:i + n])
            #end for
        #end for
    #end def
#end def


def _counter_analyzer(C):
    for k, v in C.items():
        for _ in range(v):
            yield k
#end def


class ListCountVectorizer(CountVectorizer):
    def __init__(self, **kwargs):
        kwargs.setdefault('analyzer', ListNGramAnalyzer(**kwargs))

        super(ListCountVectorizer, self).__init__(**kwargs)
    #end def
#end class


class ListHashingVectorizer(HashingVectorizer):
    def __init__(self, **kwargs):
        kwargs.setdefault('analyzer', ListNGramAnalyzer(**kwargs))
        super(ListHashingVectorizer, self).__init__(**kwargs)
    #end def
#end class


class CounterHashingVectorizer(HashingVectorizer):
    def __init__(self, **kwargs):
        kwargs.setdefault('analyzer', _counter_analyzer)
        super(CounterHashingVectorizer, self).__init__(**kwargs)
    #end def
#end class


class SpaceTokenizerTransformer(PureTransformer):
    def transform_one(self, text):
        return text.split()
#end class

@@ -79,16 +79,60 @@
 orizer',
+ 'ListNGramAnalyzer', 'ListTfidfVectorizer',
  'SpaceT
@@ -154,16 +154,32 @@
 rmer'%5D%0A%0A
+import logging%0A%0A
 from skl
@@ -296,42 +296,140 @@
 zer%0A
-%0Afrom .base import PureTransformer
+from sklearn.feature_extraction.text import TfidfVectorizer%0A%0Afrom .base import PureTransformer%0A%0Alogger = logging.getLogger(__name__)
 %0A%0A%0Ac
@@ -455,14 +455,23 @@
 zer(
-object
+PureTransformer
 ):%0A 
@@ -536,32 +536,155 @@
 ' ', **kwargs):%0A
+        nparray = kwargs.pop('nparray', False)%0A        super(ListNGramAnalyzer, self).__init__(nparray=nparray, **kwargs)%0A%0A
         if isins
@@ -1335,24 +1335,103 @@
     #end def
+%0A%0A    def transform_one(self, tokens):%0A        yield from self.__call__(tokens)
 %0A#end def%0A%0A%0A
@@ -1686,17 +1686,16 @@
 wargs))%0A
-%0A
         
@@ -1750,32 +1750,1139 @@
 gs)%0A    #end def
+%0A%0A    def fit(self, *args, **kwargs):%0A        super(ListCountVectorizer, self).fit(*args, **kwargs)%0A        logger.debug('There are %7B%7D vocabulary items in %3C%7B%7D%3E.'.format(len(self.vocabulary_), self))%0A    #end def%0A%0A    def fit_transform(self, *args, **kwargs):%0A        super(ListCountVectorizer, self).fit_transform(*args, **kwargs)%0A        logger.debug('There %7B%7D vocabulary items in %3C%7B%7D%3E.'.format(len(self.vocabulary_), self))%0A    #end def%0A#end class%0A%0A%0Aclass ListTfidfVectorizer(TfidfVectorizer):%0A    def __init__(self, **kwargs):%0A        kwargs.setdefault('analyzer', ListNGramAnalyzer(**kwargs))%0A        super(ListTfidfVectorizer, self).__init__(**kwargs)%0A    #end def%0A%0A    def fit(self, *args, **kwargs):%0A        super(ListTfidfVectorizer, self).fit(*args, **kwargs)%0A        logger.debug('There are %7B%7D vocabulary items in %3C%7B%7D%3E.'.format(len(self.vocabulary_), self))%0A    #end def%0A%0A    def fit_transform(self, *args, **kwargs):%0A        super(ListTfidfVectorizer, self).fit_transform(*args, **kwargs)%0A        logger.debug('There %7B%7D vocabulary items in %3C%7B%7D%3E.'.format(len(self.vocabulary_), self))%0A    #end def
 %0A#end class%0A%0A%0Acl

Add `ListTfidfVectorizer` and debug messages with vocabulary sizes