# -*- coding: utf-8 -*-
"""8_Stemmer_WordNetLemmatizer

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/1mBtTNtTmDcm_47wh0OVOnVRcdcz_n49u

#Porterstemmer
"""

import nltk
from nltk.stem import PorterStemmer
word_stemmer = PorterStemmer()
print(word_stemmer.stem('writing'))

import nltk
nltk.download('punkt_tab')

text="Pythoncrs are very intelligent and work very pythonly"
tokenization=nltk.word_tokenize(text)
for w in tokenization:
  print("Stemming for {} is-{}".format(w,word_stemmer.stem(w)))


  

"""#LancasterStemmer


"""






import nltk
from nltk.stem import LancasterStemmer
Lanc_stemmer = LancasterStemmer()
print(Lanc_stemmer.stem('writing'))

for w in tokenization:
  print("Stemming for {} is-{}".format(w,Lanc_stemmer.stem(w)))




"""#RegexpStemmer

"""







import nltk
from nltk.stem import RegexpStemmer
Reg_stemmer = RegexpStemmer('ing$|s$|e$|able$', min=4)
print(Reg_stemmer.stem('writing'))

tokenization=nltk.word_tokenize(text)
print(f"original text:{text}")
print("Stemming results (RegexpStemmer)")
for w in tokenization:
  stemmed_word=Reg_stemmer.stem(w)
  print("Stemming for {} is-{}".format(w,stemmed_word))





"""#SnowballStemmer

"""



import nltk
from nltk.stem import SnowballStemmer
english_stemmer = SnowballStemmer('english')
print(english_stemmer.stem ('writing'))

nltk.download('stopwords')
snowball=SnowballStemmer(language='english',ignore_stopwords=True)
words=['generous','giving','generate','having']
for word in words:
    print(word,"\n>",snowball.stem(word))





"""# WordNetLemmatizer

"""




import nltk
nltk.download('wordnet')
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()
text1="The striped bats are hanging on their feet for best"
tokenization=nltk.word_tokenize(text1)
for w in tokenization:
    print("{0:20}{1:20}".format(w,wordnet_lemmatizer.lemmatize(w)))

###!python -m spacy download en_core_web_sm
import spacy
nlp=spacy.load('en_core_web_sm')
doc=nlp("eating eats ate ability adjustable rafting meeting better")
for token in doc:
    print(token,"|",token.lemma_,"|",token.lemma)
