Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

lexrankScores

LexRank 알고리즘을 사용하여 문서 점수화

R2020a 이후

설명

예제

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 = 
  4x1 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:

          Counts: [154x3527 double]
      Vocabulary: ["From"    "fairest"    "creatures"    "we"    "desire"    "increase"    ","    "That"    "thereby"    "beauty's"    "rose"    "might"    "never"    "die"    "But"    "as"    "the"    "riper"    "should"    ...    ] (1x3527 string)
        NumWords: 3527
    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형 배열 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다. documentstokenizedDocument 배열이 아닌 경우 이는 단일 문서를 나타내고 각 요소가 단어인 행 벡터여야 합니다. 문서를 여러 개 지정하려면 tokenizedDocument 배열을 사용하십시오.

입력 bag-of-words 모델 또는 bag-of-n-grams 모델로, bagOfWords 객체 또는 bagOfNgrams 객체로 지정됩니다. bagbagOfNgrams 객체일 경우 이 함수는 각 n-gram을 단일 단어로 처리합니다.

출력 인수

모두 축소

LexRank 점수로, Nx1 벡터로 반환됩니다. 여기서 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에 개발됨