メインコンテンツ

wordCloudCounts

ワード クラウド作成のための単語数のカウント

説明

T = wordCloudCounts(str) は、ワード クラウド作成のために str 内のテキストをトークン化して前処理し、単語カウントと頻度カウントの table T を返します。関数は、英語、日本語、ドイツ語、および韓国語のテキストをサポートしています。

すべて折りたたむ

extractFileText を使用して sonnets.txt からテキストを抽出します。

str = extractFileText("sonnets.txt");

最初のソネットを表示します。

i = strfind(str,"I");
ii = strfind(str,"II");
start = i(1);
fin = ii(1);
extractBetween(str,start,fin-1)
ans = 
    "I
     
       From fairest creatures we desire increase,
       That thereby beauty's rose might never die,
       But as the riper should by time decease,
       His tender heir might bear his memory:
       But thou, contracted to thine own bright eyes,
       Feed'st thy light's flame with self-substantial fuel,
       Making a famine where abundance lies,
       Thy self thy foe, to thy sweet self too cruel:
       Thou that art now the world's fresh ornament,
       And only herald to the gaudy spring,
       Within thine own bud buriest thy content,
       And tender churl mak'st waste in niggarding:
         Pity the world, or else this glutton be,
         To eat the world's due, by the grave and thee.
     
       "

ソネット集のテキストをトークン化して前処理し、単語頻度カウントの table を作成します。

T = wordCloudCounts(str);
head(T)
     Word     Count
    ______    _____

    "thy"      281 
    "thou"     235 
    "love"     188 
    "thee"     162 
    "eyes"      90 
    "doth"      88 
    "make"      63 
    "mine"      63 

入力引数

すべて折りたたむ

入力テキスト。string 配列、文字ベクトル、または文字ベクトルの cell 配列として指定します。

string 入力の場合、関数 wordcloud および関数 wordCloudCounts は、英語、日本語、ドイツ語、および韓国語のトークン化、ストップ ワードの削除、および単語の正規化を使用します。

例: ["an example of a short document";"a second short document"]

データ型: string | char | cell

出力引数

すべて折りたたむ

重要度順に並べ替えられた単語カウントの table。table は以下の列をもちます。

Word単語の string スカラー。
Count文書内での単語の出現回数。関数は、大文字と小文字のみが異なる単語、または normalizeWords の結果として共通するステムをもつ単語のカウントをグループ化します。たとえば、関数は、"walk"、"Walking"、"walking"、および "walks" のカウントをグループ化します。

詳細

すべて折りたたむ

バージョン履歴

R2017b で導入