Spacy NER Extractor

class etk.extractors.spacy_ner_extractor.SpacyNerExtractor(extractor_name: str, nlp=<spacy.lang.en.English object>)[source]

Bases: etk.extractor.Extractor

Description
This extractor takes a list of spaCy NER tag as reference, and extract the tag matched substring from the input text

Examples

get_attr = ['PERSON', 'ORG', 'GPE']
spacy_ner_extractor = SpacyNerExtractor()
spacy_ner_extractor.extract(text=text, get_attr=get_attr)
extract(text: str, get_attr=['PERSON', 'ORG', 'GPE']) → List[etk.extraction.Extraction][source]
Parameters:
  • text (str) – the text to extract from.
  • get_attr (List[str]) – The spaCy NER attributes we’re interested in.
Returns:

the list of extraction or the empty list if there are no matches.

Return type:

List(Extraction)