Length of documents in document array
Find Number of Words in Documents
Find the number of words in an array of tokenized documents. Erase the punctuation characters so they do not get counted as words.
str = [ ... "An example of a short sentence." "A second short sentence."]; documents = tokenizedDocument(str)
documents = 2x1 tokenizedDocument: 7 tokens: An example of a short sentence . 5 tokens: A second short sentence .
documents = erasePunctuation(documents)
documents = 2x1 tokenizedDocument: 6 tokens: An example of a short sentence 4 tokens: A second short sentence
N = doclength(documents)
N = 2×1 6 4
documents — Input documents
Input documents, specified as a
N — Document lengths
vector of nonnegative integers
Document lengths, returned as a vector of nonnegative integers. The size
N is the same as the size of
Introduced in R2017b