texthero.nlp.named_entities¶
-
named_entities
(s, package='spacy')¶ Return named-entities.
Return a Pandas Series where each rows contains a list of tuples containing information regarding the given named entities.
Tuple: (entity’name, entity’label, starting character, ending character)
Under the hood, named_entities make use of Spacy name entity recognition.
- List of labels:
PERSON: People, including fictional.
NORP: Nationalities or religious or political groups.
FAC: Buildings, airports, highways, bridges, etc.
ORG : Companies, agencies, institutions, etc.
GPE: Countries, cities, states.
LOC: Non-GPE locations, mountain ranges, bodies of water.
PRODUCT: Objects, vehicles, foods, etc. (Not services.)
EVENT: Named hurricanes, battles, wars, sports events, etc.
WORK_OF_ART: Titles of books, songs, etc.
LAW: Named documents made into laws.
LANGUAGE: Any named language.
DATE: Absolute or relative dates or periods.
TIME: Times smaller than a day.
PERCENT: Percentage, including ”%“.
MONEY: Monetary values, including unit.
QUANTITY: Measurements, as of weight or distance.
ORDINAL: “first”, “second”, etc.
CARDINAL: Numerals that do not fall under another type.
Examples
>>> import texthero as hero >>> import pandas as pd >>> s = pd.Series("Yesterday I was in NY with Bill de Blasio") >>> hero.named_entities(s)[0] [('Yesterday', 'DATE', 0, 9), ('NY', 'GPE', 19, 21), ('Bill de Blasio', 'PERSON', 27, 41)]