human
I am working on the file ".ipynb_checkpoints/guardian_first_attempt-checkpoint.ipynb".
The first task is:
Create comment stemmer and TFIDF vectorizer
We will do some stemming in the comment text in order to create shorter vectors that represent each comment.
Can you write Python code for it?

Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

from sklearn.feature_extraction.text import TfidfVectorizer
import nltk.stem

english_stemmer = nltk.stem.SnowballStemmer('english')

class StemmedTfidfVectorizer(TfidfVectorizer):
    def build_analyzer(self):
        analyzer=super(StemmedTfidfVectorizer,self).build_analyzer()
        return lambda doc:(english_stemmer.stem(w) for w in analyzer(doc))