I am new to NLP and facing some challenges in performing the following task. I want to perform these order of tasks. 1.Sentenence Tokenize 2.Word tokenize on each sentence 3.Lower case 4.Stop word removal 5.Lemmatizing each word
I tried to write a function do the above task
import nltk
import numpy as np
import random
import string
from nltk.corpus import stopwords
def text_processing(input_str):
tokens = nltk.sent_tokenize(input_str)#sentence tokenizing
for words in tokens:
each_word = nltk.word_tokenize(words)#word tokeninzing
for i in each_word:
lower_words = i.lower()
stopwords_removed = [w for w in lower_words if not w in stopwords]
print(stopwords_removed)
when i call the above function
text_processing(new_doc)
I am getting this error : TypeError: argument of type 'LazyCorpusLoader' is not iterable. How to overcome this error.