ट्रांसक्राइब किए गए टेक्स्ट पर Named Entity Recognition

Python में Spoken Language Processing

Daniel Bourke

Machine Learning Engineer/YouTube Creator

spaCy इंस्टॉल करना

# spaCy इंस्टॉल करें
$ pip install spacy
# spaCy भाषा मॉडल डाउनलोड करें
$ python -m spacy download en_core_web_sm
Python में Spoken Language Processing

spaCy का उपयोग

import spacy

# spaCy भाषा मॉडल लोड करें nlp = spacy.load("en_core_web_sm")
# एक spaCy doc बनाएँ
text = ("I'd like to talk about a smartphone I ordered on July 31st "
        "from your Sydney store, my order number is 4093829. I spoke "
        "to one of your customer service team, Georgia, yesterday.")
doc = nlp(text)
Python में Spoken Language Processing

spaCy टोकन

# अलग-अलग टोकन और उनकी पोज़िशन दिखाएँ
for token in doc:
  print(token.text, token.idx)
I 0
'd 1
like 4
to 9
talk 12
about 17
a 23
smartphone 25...
Python में Spoken Language Processing

spaCy वाक्य

# doc में वाक्य दिखाएँ
for sentence in doc.sents:
  print(sentence)
I'd like to talk about a smartphone I ordered on July 31st from your Sydney store, 
my order number is 4093829.
I spoke to one of your customer service team, Georgia, yesterday.
Python में Spoken Language Processing

spaCy named entities

spaCy की कुछ बिल्ट-इन named entities:

  • PERSON लोग, काल्पनिक भी.
  • ORG कंपनियाँ, एजेंसियाँ, संस्थान आदि.
  • GPE देश, शहर, राज्य.
  • PRODUCT वस्तुएँ, वाहन, खाद्य आदि (सेवाएँ नहीं).
  • DATE निश्चित या सापेक्ष तिथियाँ/अवधियाँ.
  • TIME दिन से छोटे समय.
  • MONEY मुद्रात्मक मान, यूनिट सहित.
  • CARDINAL अंक जो किसी अन्य प्रकार में नहीं आते.
Python में Spoken Language Processing

spaCy named entities

# doc में named entities खोजें
for entity in doc.ents:
  print(entity.text, entity.label_)
July 31st DATE
Sydney GPE
4093829 CARDINAL
one CARDINAL
Georgia GPE
yesterday DATE
Python में Spoken Language Processing

कस्टम named entities

# spaCy पाइपलाइन जाँचें
print(nlp.pipe_names)
['tok2vec', 'tagger', 'parser',
 'attribute_ruler', 'lemmatizer', 'ner']
Python में Spoken Language Processing

पाइपलाइन बदलना

# ner से पहले पाइपलाइन में entity_ruler जोड़ें
ruler = nlp.add_pipe("entity_ruler", before="ner")
# रूलर में टोकन पैटर्न जोड़ें
ruler.add_patterns([{"label":"PRODUCT", "pattern": "smartphone"}])
# अपडेटेड पाइपलाइन जाँचें
nlp.pipe_names
Python में Spoken Language Processing

पाइपलाइन बदलना

['tok2vec', 'tagger', 'parser', 'attribute_ruler',
 'lemmatizer', 'entity_ruler', 'ner']
Python में Spoken Language Processing

नई पाइपलाइन का परीक्षण

# अपडेटेड पाइपलाइन से doc दोबारा बनाएँ
doc = nlp(text)
# नए entity नियम का परीक्षण करें
for entity in doc.ents:
  print(entity.text, entity.label_)
smartphone PRODUCT
July 31st DATE
Sydney GPE
4093829 CARDINAL
one CARDINAL
Georgia GPE
yesterday DATE
Python में Spoken Language Processing

चलें, spaCy के साथ अभ्यास करें!

Python में Spoken Language Processing

Preparing Video For Download...