This file contains hidden or 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.stem import WordNetLemmatizer | |
from nltk.stem import PorterStemmer | |
stemmer = PorterStemmer() | |
lemmatizer = WordNetLemmatizer() | |
print(stemmer.stem('stones')) | |
print(stemmer.stem('speaking')) | |
print(stemmer.stem('bedroom')) | |
print(stemmer.stem('jokes')) | |
print(stemmer.stem('lisa')) |
This file contains hidden or 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.stem import WordNetLemmatizer | |
lemmatizer = WordNetLemmatizer() | |
print(lemmatizer.lemmatize('playing', pos="v")) | |
print(lemmatizer.lemmatize('playing', pos="n")) | |
print(lemmatizer.lemmatize('playing', pos="a")) | |
print(lemmatizer.lemmatize('playing', pos="r")) | |
Output : | |
play |
This file contains hidden or 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.stem import WordNetLemmatizer | |
lemmatizer = WordNetLemmatizer() | |
print(lemmatizer.lemmatize('playing', pos="v")) | |
Output: | |
play |
This file contains hidden or 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.stem import WordNetLemmatizer | |
lemmatizer = WordNetLemmatizer() | |
print(lemmatizer.lemmatize('increases')) | |
Output: | |
increase |
This file contains hidden or 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.stem import PorterStemmer | |
stemmer = PorterStemmer() | |
print(stemmer.stem('increases')) | |
Output: | |
increas |
This file contains hidden or 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.stem import SnowballStemmer | |
french_stemmer = SnowballStemmer('french') | |
print(french_stemmer.stem("French word")) |
This file contains hidden or 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.stem import SnowballStemmer | |
print(SnowballStemmer.languages) | |
Output: | |
'danish', 'dutch', 'english', 'finnish', 'french', 'german', 'hungarian', 'italian', | |
'norwegian', 'porter', 'portuguese', 'romanian', 'russian', 'spanish', 'swedish' |
This file contains hidden or 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.stem import PorterStemmer | |
stemmer = PorterStemmer() | |
print(stemmer.stem('working')) | |
print(stemmer.stem('worked')) | |
Output: | |
work | |
work |
This file contains hidden or 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 wordnet | |
antonyms = [] | |
for syn in wordnet.synsets("small"): | |
for l in syn.lemmas(): | |
if l.antonyms(): | |
antonyms.append(l.antonyms()[0].name()) | |
print(antonyms) | |
Output: |
This file contains hidden or 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 wordnet | |
synonyms = [] | |
for syn in wordnet.synsets('Computer'): | |
for lemma in syn.lemmas(): | |
synonyms.append(lemma.name()) | |
print(synonyms) | |
Output: |