Last active
July 18, 2019 06:08
-
-
Save shubham-singh-ss/5c972387542b468a94e71f94aee80f41 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
from nltk.corpus import stopwords | |
from nltk.tokenize import word_tokenize | |
import nltk | |
from nltk.stem import WordNetLemmatizer | |
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) | |
print(filtered_sentence) | |
lemma_word = [] | |
import nltk | |
from nltk.stem import WordNetLemmatizer | |
wordnet_lemmatizer = WordNetLemmatizer() | |
for w in filtered_sentence: | |
word1 = wordnet_lemmatizer.lemmatize(w, pos = "n") | |
word2 = wordnet_lemmatizer.lemmatize(word1, pos = "v") | |
word3 = wordnet_lemmatizer.lemmatize(word2, pos = ("a")) | |
lemma_word.append(word3) | |
print(lemma_word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment