17 lines
442 B
ReStructuredText
17 lines
442 B
ReStructuredText
>>> import spacy
|
|
>>> import en_core_web_sm
|
|
|
|
>>> nlp = en_core_web_sm.load()
|
|
>>> _ = nlp.add_pipe("merge_entities")
|
|
|
|
>>> sentence = ('Python was introduced in 1989 by Guido van '
|
|
... 'Rossum at Stichting Mathematisch Centrum in Amsterdam.')
|
|
|
|
>>> for token in nlp(sentence):
|
|
... if token.ent_type_:
|
|
... print(f'{token.ent_type_}: {token.text}')
|
|
DATE: 1989
|
|
PERSON: Guido van Rossum
|
|
ORG: Stichting Mathematisch Centrum
|
|
GPE: Amsterdam
|