extractSummary
문서에서 요약 추출
구문
설명
예제
토큰화된 문서로 구성된 배열을 만듭니다.
str = [
"The quick brown fox jumped over the lazy dog."
"The fox jumped over the dog."
"The lazy dog saw a fox jumping."
"There seem to be animals jumping other animals."
"There are quick animals and lazy animals"];
documents = tokenizedDocument(str);extractSummary 함수를 사용하여 문서 요약을 추출합니다. 기본적으로 이 함수는 입력 문서의 1/10만큼을 올림한 양을 선택합니다.
summary = extractSummary(documents)
summary = tokenizedDocument: 10 tokens: The quick brown fox jumped over the lazy dog .
더 많은 양의 요약을 지정하려면 'SummarySize' 옵션을 사용하십시오. 3개 문서 분량의 요약을 추출합니다.
summary = extractSummary(documents,'SummarySize',3)summary =
3×1 tokenizedDocument:
10 tokens: The quick brown fox jumped over the lazy dog .
7 tokens: The fox jumped over the dog .
9 tokens: There seem to be animals jumping other animals .
토큰화된 문서로 구성된 배열을 만듭니다.
str = [
"The quick brown fox jumped over the lazy dog."
"The fox jumped over the dog."
"The lazy dog saw a fox jumping."
"There seem to be animals jumping over other animals."
"There are quick animals and lazy animals"];
documents = tokenizedDocument(str);3개 문서 분량의 요약을 추출합니다. 두 번째 출력값 scores에 요약 문서의 중요도 점수가 들어 있습니다.
[summary,scores] = extractSummary(documents,'SummarySize',3)summary =
3×1 tokenizedDocument:
10 tokens: The quick brown fox jumped over the lazy dog .
10 tokens: There seem to be animals jumping over other animals .
7 tokens: The fox jumped over the dog .
scores = 3×1
0.2426
0.2174
0.1911
점수를 막대 차트로 시각화합니다.
figure bar(scores) xlabel("Summary Document") ylabel("Score") title("Summary Document Importance")

단일 문서를 요약하려면 그 문서를 문장으로 구성된 배열로 분할한 다음 extractSummary 함수를 사용해야 합니다.
문서를 포함하는 string형 스칼라를 만듭니다.
str = ... "There is a quick fox. The fox is brown. There is a dog which " + ... "is lazy. The dog is very lazy. The fox jumped over the dog. " + ... "The quick brown fox jumped over the lazy dog.";
splitSentences 함수를 사용하여 문자열을 문장으로 분할합니다.
str = splitSentences(str)
str = 6×1 string
"There is a quick fox."
"The fox is brown."
"There is a dog which is lazy."
"The dog is very lazy."
"The fox jumped over the dog."
"The quick brown fox jumped over the lazy dog."
문장들을 포함하는 토큰화된 문서 배열을 만듭니다.
documents = tokenizedDocument(str)
documents =
6×1 tokenizedDocument:
6 tokens: There is a quick fox .
5 tokens: The fox is brown .
8 tokens: There is a dog which is lazy .
6 tokens: The dog is very lazy .
7 tokens: The fox jumped over the dog .
10 tokens: The quick brown fox jumped over the lazy dog .
extractSummary 함수를 사용하여 문장에서 요약을 추출합니다. 3개 문서 분량의 요약을 반환하기 위해 'SummarySize' 옵션을 3으로 설정하고, 요약 문서가 입력 문서와 동일한 순서로 표시되도록 하기 위해 'OrderBy' 옵션을 'position'으로 설정합니다.
summary = extractSummary(documents,'SummarySize',3,'OrderBy','position')
summary =
3×1 tokenizedDocument:
6 tokens: There is a quick fox .
7 tokens: The fox jumped over the dog .
10 tokens: The quick brown fox jumped over the lazy dog .
joinWords 함수를 사용해 문서를 문자열로 변환한 후 join 함수를 사용해 문장을 연결하여 문장을 단일 문서로 재구성합니다.
sentences = joinWords(summary); summaryStr = join(sentences)
summaryStr = "There is a quick fox . The fox jumped over the dog . The quick brown fox jumped over the lazy dog ."
replace 함수를 사용하여 주위에 있는 문장 부호 문자를 제거합니다.
punctuationRight = ["." "," "’" ")" ":" "?" "!"]; summaryStr = replace(summaryStr," " + punctuationRight,punctuationRight); punctuationLeft = ["(" "‘"]; summaryStr = replace(summaryStr,punctuationLeft + " ",punctuationLeft)
summaryStr = "There is a quick fox. The fox jumped over the dog. The quick brown fox jumped over the lazy dog."
입력 인수
입력 문서로, tokenizedDocument 배열로 지정됩니다.
이름-값 인수
선택적 인수 쌍을 Name1=Value1,...,NameN=ValueN으로 지정합니다. 여기서 Name은 인수 이름이고 Value는 대응값입니다. 이름-값 인수는 다른 인수 뒤에 와야 하지만, 인수 쌍의 순서는 상관없습니다.
R2021a 이전 릴리스에서는 각 이름과 값을 쉼표로 구분하고 Name을 따옴표로 묶으십시오.
예: extractSummary(documents,'ScoringMethod','lexrank')는 documents에서 요약을 추출하고 점수화 방법 옵션을 'lexrank'로 설정합니다.
발췌 요약에 사용되는 점수화 방법으로, 'ScoringMethod'와 함께 다음 중 하나가 쉼표로 구분되어 지정됩니다.
'textrank'– TextRank 알고리즘을 사용합니다.'lexrank'– LexRank 알고리즘을 사용합니다.'mmr'– MMR 알고리즘을 사용합니다.
MMR 점수화에 대한 쿼리 문서로, 'Query'와 함께 tokenizedDocument 스칼라, 단어로 구성된 string형 배열 또는 문자형 벡터로 구성된 셀형 배열이 쉼표로 구분되어 지정됩니다. 'Query'가 tokenizedDocument 스칼라가 아닌 경우 이는 단일 문서를 나타내고 각 요소가 단어인 행 벡터여야 합니다.
이 옵션은 'ScoringMethod'가 'mmr'인 경우에만 효력이 있습니다.
요약 크기로, 'SummarySize'와 함께 다음 중 하나가 쉼표로 구분되어 지정됩니다.
(0,1) 범위의 스칼라 – 지정된 비율에 해당하는 분량을 올림한 만큼의 입력 문서를 추출합니다. 이 경우 요약 문서의 개수는
ceil(SummarySize*numDocuments)입니다. 여기서numDocuments는 입력 문서의 개수입니다.양의 정수 – 지정된 개수만큼의 문서로 구성된 요약을 추출합니다.
SummarySize가 입력 문서 수보다 크거나 같으면 이 함수는'OrderBy'옵션에 따라 정렬된 입력 문서를 반환합니다.Inf–'OrderBy'옵션에 따라 정렬된 입력 문서를 반환합니다.
데이터형: double
요약 문서의 순서로, 'OrderBy'와 함께 다음 중 하나가 쉼표로 구분되어 지정됩니다.
'score'–'ScoringMethod'옵션에 따라 점수순으로 문서를 정렬합니다.'position'– 입력 문서의 문서 순서를 유지합니다.
출력 인수
버전 내역
R2020a에 개발됨
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)