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 で導入