주요 콘텐츠

splitSentences

텍스트를 문장으로 분할

설명

newStr = splitSentences(str)str을 문장으로 구성된 배열로 분할합니다.

예제

newDocuments = splitSentences(document)는 단일 tokenizedDocument 객체를 문장으로 구성된 tokenizedDocument 배열로 분할합니다.

예제

모두 축소

예제 파일 sonnets.txt에서 텍스트를 읽어온 다음 문장으로 분할합니다.

filename = "sonnets.txt";
str = extractFileText(filename);
sentences = splitSentences(str);

처음 몇 개의 문장을 표시합니다.

sentences(1:10)
ans = 10×1 string
    "THE SONNETS"
    "by William Shakespeare"
    "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."
    "II"
    "When forty winters shall besiege thy brow,↵And dig deep trenches in thy beauty's field,↵Thy youth's proud livery so gazed on now,↵Will be a tatter'd weed of small worth held:↵Then being asked, where all thy beauty lies,↵Where all the treasure of thy lusty days;↵To say, within thine own deep sunken eyes,↵Were an all-eating shame, and thriftless praise."
    "How much more praise deserv'd thy beauty's use,↵If thou couldst answer 'This fair child of mine↵Shall sum my count, and make my old excuse,'↵Proving his beauty by succession thine!"
    "This were to be new made when thou art old,↵And see thy blood warm when thou feel'st it cold."
    "III"
    "Look in thy glass and tell the face thou viewest↵Now is the time that face should form another;↵Whose fresh repair if now thou not renewest,↵Thou dost beguile the world, unbless some mother."

입력 인수

모두 축소

입력 텍스트로, string형 스칼라, 문자형 벡터 또는 문자형 벡터를 포함하는 스칼라 셀형 배열로 지정됩니다.

데이터형: string | char | cell

입력 문서로, 스칼라 tokenizedDocument 객체로 지정됩니다.

출력 인수

모두 축소

출력 텍스트로, string형 배열 또는 문자형 벡터로 구성된 셀형 배열로 반환됩니다.

str이 string형이면 newStr도 string형입니다. 그렇지 않으면, newStr은 문자형 벡터로 구성된 셀형 배열입니다.

데이터형: string | cell

출력 문서로, tokenizedDocument 배열로 반환됩니다.

알고리즘

이모티콘이나 이모지 문자가 종결 문장 부호 문자 뒤에 나오면, 이 함수는 이모티콘과 이모지 다음에서 문장을 분할합니다.

버전 내역

R2018a에 개발됨