Main Content

doclength

문서 배열에 포함된 문서의 길이

설명

예제

N = doclength(documents)documents에 있는 각 문서의 토큰 수를 반환합니다.

예제

모두 축소

토큰화된 문서로 구성된 배열에 포함된 단어 개수를 구합니다. 문장 부호는 단어로 계산되지 않도록 지웁니다.

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

입력 인수

모두 축소

입력 문서로, tokenizedDocument 배열로 지정됩니다.

출력 인수

모두 축소

문서 길이로, 음이 아닌 정수로 구성된 벡터로 반환됩니다. N의 크기는 documents의 크기와 같습니다.

버전 내역

R2017b에 개발됨