Main Content

removeShortWords

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

説明

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

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

すべて折りたたむ

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

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

   3 tokens: example short sentence

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

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

          Counts: [2x4 double]
      Vocabulary: ["example"    "short"    "sentence"    "second"]
        NumWords: 4
    NumDocuments: 2

入力引数

すべて折りたたむ

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

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

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

出力引数

すべて折りたたむ

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

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

バージョン履歴

R2017b で導入