<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Named Entity Extraction
Named entity extraction task aims to extract phrases from plain text that correpond to entities.
Polyglot recognizes 3 categories of entities
Step1:  Download Necessary Models
Step3:  Example
Entities inside a text object or a sentence are represented as chunks.
Each chunk identifies the start and the end indices of the word subsequence within the text.
Step4:  We can query all entities mentioned in a text.
Step5:  Or, we can query entites per sentence
Step6:  By doing more careful inspection of the second entity Benjamin Netanyahu, we can locate the position of the entity within the sentence.
Step7:  Command Line Interface
<ASSISTANT_TASK:>
Python Code:
from polyglot.downloader import downloader
print(downloader.supported_languages_table("ner2", 3))
Explanation: Named Entity Extraction
Named entity extraction task aims to extract phrases from plain text that correpond to entities.
Polyglot recognizes 3 categories of entities:
Locations (Tag: I-LOC): cities, countries, regions, continents, neighborhoods,  administrative divisions ...
Organizations (Tag: I-ORG): sports teams, newspapers, banks, universities, schools, non-profits, companies, ...
Persons (Tag: I-PER): politicians, scientists, artists, atheletes ...
Languages Coverage
The models were trained on datasets extracted automatically from Wikipedia.
Polyglot currently supports 40 major languages.
End of explanation
%%bash
polyglot download embeddings2.en ner2.en
Explanation: Download Necessary Models
End of explanation
from polyglot.text import Text
blob = The Israeli Prime Minister Benjamin Netanyahu has warned that Iran poses a "threat to the entire world".
text = Text(blob)
Explanation: Example
Entities inside a text object or a sentence are represented as chunks.
Each chunk identifies the start and the end indices of the word subsequence within the text.
End of explanation
text.entities
Explanation: We can query all entities mentioned in a text.
End of explanation
for sent in text.sentences:
  print(sent, "\n")
  for entity in sent.entities:
    print(entity.tag, entity)
Explanation: Or, we can query entites per sentence
End of explanation
benjamin = sent.entities[1]
sent.words[benjamin.start: benjamin.end]
Explanation: By doing more careful inspection of the second entity Benjamin Netanyahu, we can locate the position of the entity within the sentence.
End of explanation
!polyglot --lang en tokenize --input testdata/cricket.txt |  polyglot --lang en ner | tail -n 20
Explanation: Command Line Interface
End of explanation
<END_TASK>