spacy-doc-span-token

05-10-2022 || 02:03
Tags: #nlp #spacy

spacy-doc-span-token

Doc

Doc can be manually used to create doc object from text.

import spacy
from spacy.tokens import Doc, Span, Token

nlp = spacy.blank('en')

words = ['Hello', 'World', '!']
spaces = [True, False, False]

doc = Doc(nlp.vocab, words=words, spaces=spaces)

Span

Span is the slice of the doc.

span = Span(doc, 0, 2)

References