spacy text annotation dict comprehension code example
Example: spacy text annotation dict comprehension
import spacy
nlp = spacy.load('en_core_web_sm') # or some other model
text_to_be_annotated = nlp('Put your long to-be-annotated text here')
# pos: part-of-speech tagging
# lemma: base form of the word
# vector: embedding of the token (optional)
annotated_text = {token : (token.pos_, token.lemma_, token.vector)
for token in text_to_be_annotated}