Answers for "spacy get number of tokens"

0

spacy get number of tokens

import spacy

nlp = spacy.load("en_core_web_sm") # or a different available model

s = "This is my beautiful string"

# spaCy counts the number of tokens such as
# words, numbers, puntuation marks etc.
len(nlp(s)) 
>>> 5
Posted by: Guest on June-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language