STAY WITH US

[Hindi]NLP 16# Lemmatization |NLP|Python 3|Natural Language Processing|2019

[Hindi]NLP 16# Lemmatization |NLP|Python 3|Natural Language Processing|2019


Code:

# -*- coding: utf-8 -*-
"""NLP_Ex10.ipynb

Automatically generated by Colaboratory.

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

import spacy

nlp = spacy.load('en_core_web_sm')

doc1 = nlp(u'I am a runner running in a race beacause I love to run Since I ran this morning')

for token in doc1:
  print(token.text,'\t',token.pos_,'\t',token.lemma,'\t',token.lemma_)

def show_lemma(text):
  for token in text:
    print(f"{token.text:{12}} {token.pos_:{6}} {token.lemma:<{22}} {token.lemma_}")

doc2 = nlp(u'I saw ten mice this morning.')

show_lemma(doc1)

YouTube:


Recommended Book:

Post a Comment

0 Comments