Created
January 30, 2021 17:40
-
-
Save AyishaR/cff91cf83653d4626de70605753e4335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sno = nltk.stem.SnowballStemmer('english') # Initializing stemmer | |
wordcloud = [[], [], [], [], [], [], []] | |
all_sentences = [] # All cleaned sentences | |
for x in range(len(df['Questions'].values)): | |
question = df['Questions'].values[x] | |
classname = df['Category0'].values[x] | |
cleaned_sentence = [] | |
sentence = removeURL(question) | |
sentence = removeHTML(sentence) | |
sentence = onlyAlphabets(sentence) | |
sentence = sentence.lower() | |
for word in sentence.split(): | |
#if word not in stop: | |
stemmed = sno.stem(word) | |
cleaned_sentence.append(stemmed) | |
wordcloud[class_names.index(classname)].append(word) | |
all_sentences.append(' '.join(cleaned_sentence)) | |
# add as column in dataframe | |
X = all_sentences |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment