Last active
July 18, 2019 06:07
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
from nltk.corpus import stopwords | |
from nltk.tokenize import word_tokenize | |
from nltk.stem import PorterStemmer | |
set(stopwords.words('english')) | |
text = """He determined to drop his litigation with the monastry, and relinguish his claims to the wood-cuting and | |
fishery rihgts at once. He was the more ready to do this becuase the rights had become much less valuable, and he had | |
indeed the vaguest idea where the wood and river in question were.""" | |
stop_words = set(stopwords.words('english')) | |
word_tokens = word_tokenize(text) | |
filtered_sentence = [] | |
for w in word_tokens: | |
if w not in stop_words: | |
filtered_sentence.append(w) | |
Stem_words = [] | |
ps =PorterStemmer() | |
for w in filtered_sentence: | |
rootWord=ps.stem(w) | |
Stem_words.append(rootWord) | |
print(filtered_sentence) | |
print(Stem_words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment