I'm a newbie to stackoverflow. Now I'm following NLP code from Kaggle for studying. I keep getting "maximum recursion depth exceeded in comparison" error and my kernel dies on jupyter notebook. I have already tried import sys and sys.setrecursionlimit(1500), but it doesn't work. Please help me!
#Top words after stemming operation
#collect vocabulary count
#create the object of tfid vectorizer
tfid_vectorizer = TfidfVectorizer("english")
#fit the vectorizer using the text data
tfid_vectorizer.fit(data['text'])
#collect the vocabulary items used in the vectorizer
dictionary = tfid_vectorizer.vocabulary_.items()
#Bar plot of top words after stemming
#lists to store the vocab and counts
vocab = []
count = []
#iterate through each vocab and count append the value to designated lists
for key, value in dictionary:
vocab.append(key)
count.append(value)
#store the count in pandas dataframe with vocab as index
vocab_after_stem = pd.Series(count, index=vocab)
#sort the dataframe
vocab_after_stem = vocab_after_stem.sort_values(ascending=False)
#plot of the top vocab
top_vocab = vocab_after_stem.head(20)
top_vocab.plot(kind = 'barh', figsize=(5,10), xlim = (15120,15145))
#Histogram of text length of each writer
def length(text):
return length(text)
#Apply the function to each example
data['length'] = data['text'].apply(length)
data.head(10)