メインコンテンツ

removeLongWords

文書または bag-of-words モデルからの長い単語の削除

説明

newDocuments = removeLongWords(documents,len) は、長さが len 以上の単語を documents から削除します。

newBag = removeLongWords(bag,len) は、長さが len 以上の単語を bagOfWords オブジェクト bag から削除します。

すべて折りたたむ

文書から 7 文字以上の単語を削除します。

document = tokenizedDocument("An example of a short sentence");
newDocument = removeLongWords(document,7)
newDocument = 
  tokenizedDocument:

   4 tokens: An of a short

bag-of-words モデルから 7 文字以上の単語を削除します。

documents = tokenizedDocument([ ...
    "an example of a short sentence"
    "a second short sentence"]);
bag = bagOfWords(documents);
newBag = removeLongWords(bag,7)
newBag = 
  bagOfWords with properties:

        NumWords: 5
          Counts: [2×5 double]
      Vocabulary: ["an"    "of"    "a"    "short"    "second"]
    NumDocuments: 2

入力引数

すべて折りたたむ

入力文書。tokenizedDocument 配列として指定します。

入力の bag-of-words モデル。bagOfWords オブジェクトとして指定します。

削除する単語の最小長。正の整数として指定します。関数は、len 文字以上の単語を削除します。

出力引数

すべて折りたたむ

出力文書。tokenizedDocument 配列として返されます。

出力の bag-of-words モデル。bagOfWords オブジェクトとして返されます。

バージョン履歴

R2017b で導入