भाषाई फीचर्स

spaCy के साथ Natural Language Processing

Azadeh Mobasher

Principal Data Scientist

POS टैगिंग

  • POS टैग्स संदर्भ पर निर्भर करते हैं: आसपास के शब्द और उनके टैग्स
import spacy
nlp = spacy.load("en_core_web_sm")
text = "My cat will fish for a fish tomorrrow in a fishy way."
print([(token.text, token.pos_, spacy.explain(token.pos_)) 
        for token in nlp(text)])

POS टैगिंग उदाहरण

spaCy के साथ Natural Language Processing

POS का महत्व क्या है?

 

  • कई NLP कार्यों के लिए बेहतर सटीकता

 

I will fish tomorrow.

I ate fish.

 

  • अनुवाद सिस्टम का उपयोग-केस

 

verb -> pescaré

noun -> pescado
spaCy के साथ Natural Language Processing

POS का महत्व क्या है?

 

  • Word-sense disambiguation (WSD) वह समस्या है जिसमें तय करना होता है कि वाक्य में किसी शब्द का कौन सा अर्थ प्रयुक्त हुआ है।
  • शब्द का सही अर्थ निकालना machine translation आदि में अहम है।

WSD उदाहरण

spaCy के साथ Natural Language Processing

Word-sense disambiguation

import spacy
nlp = spacy.load("en_core_web_sm")

verb_text = "I will fish tomorrow."
noun_text = "I ate fish."


print([(token.text, token.pos_) for token in nlp(verb_text) if "fish" in token.text], "\n") print([(token.text, token.pos_) for token in nlp(noun_text) if "fish" in token.text])
[('fish', 'VERB', 'verb')] 
[('fish', 'NOUN', 'noun')]
spaCy के साथ Natural Language Processing

डिपेंडेंसी पार्सिंग

  • वाक्य की सिंटैक्स की जाँच करता है
  • दो टोकन के बीच लिंक दिखाता है
  • परिणाम एक ट्री होता है

डिपेंडेंसी पार्सिंग का उदाहरण

spaCy के साथ Natural Language Processing

डिपेंडेंसी पार्सिंग और spaCy

 

  • Dependency label दो टोकन के बीच वाक्य-रचना संबंध का प्रकार बताता है

 

Dependency label विवरण
nsubj Nominal subject
root Root
det Determiner
dobj Direct object
aux Auxiliary
spaCy के साथ Natural Language Processing

डिपेंडेंसी पार्सिंग और displaCy

  • displaCy डिपेंडेंसी ट्री ड्रॉ कर सकता है
doc = nlp("We understand the differences.")

spacy.displacy.serve(doc, style="dep")

displaCy के साथ डिपेंडेंसी पार्सर का उदाहरण

spaCy के साथ Natural Language Processing

डिपेंडेंसी पार्सिंग और spaCy

  • किसी टोकन का डिपेंडेंसी लेबल पाने के लिए .dep_ एट्रिब्यूट

 

doc = nlp("We understand the differences.")
print([(token.text, token.dep_, spacy.explain(token.dep_)) for token in doc])
[('We', 'nsubj', 'nominal subject'), ('understand', 'ROOT', 'root'),
('the', 'det', 'determiner'), ('differences', 'dobj', 'direct object'),
('.', 'punct', 'punctuation')]
spaCy के साथ Natural Language Processing

अभ्यास करते हैं!

spaCy के साथ Natural Language Processing

Preparing Video For Download...