メインコンテンツ

lexrankScores

R2026b

LexRank アルゴリズムによる文書スコアリング

説明

scores = lexrankScores(documents) は、LexRank アルゴリズムを使用し、ペア単位の類似度値に基づいて指定された文書の重要度をスコアリングします。この関数はコサイン類似度を使用し、PageRank アルゴリズムを使用して重要度を計算します。

例

scores = lexrankScores(bag) は、bag-of-words または bag-of-n-grams モデルによって符号化された文書にスコアを付けます。

例

例

すべて折りたたむ

トークン化された文書の配列を作成します。

str = [
    "the quick brown fox jumped over the lazy dog"
    "the fast brown fox jumped over the lazy dog"
    "the lazy dog sat there and did nothing"
    "the other animals sat there watching"];
documents = tokenizedDocument(str)
documents = 
  4×1 tokenizedDocument:

    9 tokens: the quick brown fox jumped over the lazy dog
    9 tokens: the fast brown fox jumped over the lazy dog
    8 tokens: the lazy dog sat there and did nothing
    6 tokens: the other animals sat there watching

LexRank スコアを計算します。

scores = lexrankScores(documents);

スコアを棒グラフで可視化します。

figure
bar(scores)
xlabel("Document")
ylabel("Score")
title("LexRank Scores")

Figure contains an axes object. The axes object with title LexRank Scores, xlabel Document, ylabel Score contains an object of type bar.

sonnets.csv のテキスト データから bag-of-words モデルを作成します。

filename = "sonnets.csv";
tbl = readtable(filename,'TextType','string');
textData = tbl.Sonnet;
documents = tokenizedDocument(textData);
bag = bagOfWords(documents)
bag = 
  bagOfWords with properties:

        NumWords: 3527
          Counts: [154×3527 double]
      Vocabulary: ["From"    "fairest"    "creatures"    "we"    "desire"    "increase"    ","    "That"    "thereby"    "beauty's"    "rose"    "might"    "never"    "die"    "But"    "as"    "the"    "riper"    "should"    "by"    …    ] (1×3527 string)
    NumDocuments: 154

各ソネットの LexRank スコアを計算します。

scores = lexrankScores(bag);

スコアを棒グラフで可視化します。

figure
bar(scores)
xlabel("Document")
ylabel("Score")
title("LexRank Scores")

Figure contains an axes object. The axes object with title LexRank Scores, xlabel Document, ylabel Score contains an object of type bar.

入力引数

すべて折りたたむ

入力文書。tokenizedDocument 配列、単語の string 配列、または文字ベクトルの cell 配列として指定します。documents は、tokenizedDocument 配列でない場合、各要素が単語である単一の文書を表す行ベクトルでなければなりません。複数の文書を指定するには、tokenizedDocument 配列を使用します。

入力の bag-of-words モデルまたは bag-of-n-grams モデル。bagOfWords オブジェクトまたは bagOfNgrams オブジェクトとして指定します。bag が bagOfNgrams オブジェクトの場合、関数は各 n-gram を 1 つの単語として扱います。

出力引数

すべて折りたたむ

LexRank スコア。N 行 1 列のベクトルとして返されます。ここで、scores(i) は i 番目の入力文書のスコアに対応し、N は入力文書の数です。

参照

[1] Erkan, Günes, and Dragomir R. Radev. "LexRank: Graph-based Lexical Centrality as Salience in Text Summarization." Journal of Artificial Intelligence Research 22 (2004): 457-479.

バージョン履歴

R2020a で導入