- Python Machine Learning By Example
- Yuxi (Hayden) Liu
- 187字
- 2021-07-02 12:41:40
Named-entity recognition
Given a text sequence, the named-entity recognition (NER) task is to locate and identify words or phrases that are of definitive categories such as names of persons, companies, locations, and dates. We will briefly mention it again in Chapter 4, Detecting Spam Email with Naive Bayes.
As an appetizer, let's take a peep at an example of using spaCy for NER.
First, tokenize an input sentence, The book written by Hayden Liu in 2018 was sold at $30 in America, as usual as shown in the following command:
>>> tokens3 = nlp('The book written by Hayden Liu in 2018 was sold at $30 in America')
The resultant token object contains an attribute called ents, which is the named entities. We can extract the tagging for each recognized named entity as follows:
print([(token_ent.text, token_ent.label_) for token_ent in tokens3.ents])
[('Hayden Liu', 'PERSON'), ('2018', 'DATE'), ('30', 'MONEY'), ('America', 'GPE')]
We can see from the results that Hayden Liu is PERSON, 2018 is DATE, 30 is MONEY, and America is GPE (country). Please refer to https://spacy.io/api/annotation#section-named-entities for a full list of named entity tags.
- ABB工業(yè)機(jī)器人編程全集
- 大數(shù)據(jù)戰(zhàn)爭(zhēng):人工智能時(shí)代不能不說(shuō)的事
- 數(shù)據(jù)庫(kù)原理與應(yīng)用技術(shù)學(xué)習(xí)指導(dǎo)
- Zabbix Network Monitoring(Second Edition)
- Hands-On Cybersecurity with Blockchain
- 讓每張照片都成為佳作的Photoshop后期技法
- 西門子S7-200 SMART PLC實(shí)例指導(dǎo)學(xué)與用
- 永磁同步電動(dòng)機(jī)變頻調(diào)速系統(tǒng)及其控制(第2版)
- 21天學(xué)通Visual Basic
- RPA(機(jī)器人流程自動(dòng)化)快速入門:基于Blue Prism
- 液壓機(jī)智能故障診斷方法集成技術(shù)
- 筆記本電腦電路分析與故障診斷
- 深度學(xué)習(xí)原理與 TensorFlow實(shí)踐
- 大數(shù)據(jù):從基礎(chǔ)理論到最佳實(shí)踐
- 輸送技術(shù)、設(shè)備與工業(yè)應(yīng)用