STAY WITH US

[Hindi]NLP 24# Visualization of N.E.R |NLP|Python 3|Natural Language Processing|2019

[Hindi]NLP 24# Visualization of N.E.R  |NLP|Python 3|Natural Language Processing|2019

Code:

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

Automatically generated by Colaboratory.


"""

import spacy

nlp = spacy.load('en_core_web_sm')

from spacy import displacy

doc = nlp(u"Over the last quater Apple sold nearly 20 thousand ipods for a profit of $6 million."
         u"By contrast Sony only sold 8 thousand Walkman music players")

displacy.render(doc, style='ent', jupyter=True)

for sent in doc.sents:
  displacy.render(doc, style='ent', jupyter=True)

colors = {'ORG':'#aa9cfc'}
options = {'ents':['PRODUCT','ORG'],'colors':colors}

displacy.render(doc, style='ent', jupyter=True, options=options)

colors = {'ORG':'linear-gradient(90deg,#aa9cfc,#fc9ce7)'}
options = {'ents':['PRODUCT','ORG'],'colors':colors}

displacy.render(doc, style='ent', jupyter=True, options=options)

ors = {'ORG':'linear-gradient(180deg,yellow,red)'}
options = {'ents':['PRODUCT','ORG'],'colors':colors}

displacy.render(doc, style='ent', jupyter=True, options=options)

YouTube:


Recommended Book:

Post a Comment

0 Comments