Spacyで文から国名を取得

4月 4, 2021

事前準備

pip install spacy

python -m spacy download en_core_web_sm

コード

import spacy

nlp = spacy.load("en_core_web_sm")

doc= nlp('College of London in UK x.xxx@xxx.ac.uk')

for ent in doc.ents:
    if ent.label_ == "GPE":
        print(ent.text, ent.label_)

NLP,Spacy

Posted by vastee