From e8b9cee6fd942298145d13f0264ce430e50947d2 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Mon, 18 Nov 2019 12:41:48 +0100 Subject: [PATCH] Make example consistent with model (closes #4587) [ci skip] --- website/docs/usage/linguistic-features.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/usage/linguistic-features.md b/website/docs/usage/linguistic-features.md index 0b274b2b6..db3aac686 100644 --- a/website/docs/usage/linguistic-features.md +++ b/website/docs/usage/linguistic-features.md @@ -435,22 +435,22 @@ import spacy from spacy.tokens import Span nlp = spacy.load("en_core_web_sm") -doc = nlp("FB is hiring a new Vice President of global policy") +doc = nlp("fb is hiring a new vice president of global policy") ents = [(e.text, e.start_char, e.end_char, e.label_) for e in doc.ents] print('Before', ents) -# the model didn't recognise "FB" as an entity :( +# the model didn't recognise "fb" as an entity :( fb_ent = Span(doc, 0, 1, label="ORG") # create a Span for the new entity doc.ents = list(doc.ents) + [fb_ent] ents = [(e.text, e.start_char, e.end_char, e.label_) for e in doc.ents] print('After', ents) -# [('FB', 0, 2, 'ORG')] 🎉 +# [('fb', 0, 2, 'ORG')] 🎉 ``` Keep in mind that you need to create a `Span` with the start and end index of the **token**, not the start and end index of the entity in the document. In -this case, "FB" is token `(0, 1)` – but at the document level, the entity will +this case, "fb" is token `(0, 1)` – but at the document level, the entity will have the start and end indices `(0, 2)`. #### Setting entity annotations from array {#setting-from-array}