Change example title to Dr.

Change example title to Dr. so the current model does exclude the title
in the initial example.
This commit is contained in:
Adriane Boyd 2020-06-16 20:36:21 +02:00
parent a6abdfbc3c
commit f0fd77648f
1 changed files with 6 additions and 6 deletions

View File

@ -1158,17 +1158,17 @@ what you need for your application.
> available corpus. > available corpus.
For example, the corpus spaCy's [English models](/models/en) were trained on For example, the corpus spaCy's [English models](/models/en) were trained on
defines a `PERSON` entity as just the **person name**, without titles like "Mr" defines a `PERSON` entity as just the **person name**, without titles like "Mr."
or "Dr". This makes sense, because it makes it easier to resolve the entity type or "Dr.". This makes sense, because it makes it easier to resolve the entity
back to a knowledge base. But what if your application needs the full names, type back to a knowledge base. But what if your application needs the full
_including_ the titles? names, _including_ the titles?
```python ```python
### {executable="true"} ### {executable="true"}
import spacy import spacy
nlp = spacy.load("en_core_web_sm") nlp = spacy.load("en_core_web_sm")
doc = nlp("Dr Alex Smith chaired first board meeting of Acme Corp Inc.") doc = nlp("Dr. Alex Smith chaired first board meeting of Acme Corp Inc.")
print([(ent.text, ent.label_) for ent in doc.ents]) print([(ent.text, ent.label_) for ent in doc.ents])
``` ```
@ -1233,7 +1233,7 @@ def expand_person_entities(doc):
# Add the component after the named entity recognizer # Add the component after the named entity recognizer
nlp.add_pipe(expand_person_entities, after='ner') nlp.add_pipe(expand_person_entities, after='ner')
doc = nlp("Dr Alex Smith chaired first board meeting of Acme Corp Inc.") doc = nlp("Dr. Alex Smith chaired first board meeting of Acme Corp Inc.")
print([(ent.text, ent.label_) for ent in doc.ents]) print([(ent.text, ent.label_) for ent in doc.ents])
``` ```