Split text into sentences
Split Text into Sentences
Read the text from the example file
sonnets.txt and split it into sentences.
filename = "sonnets.txt"; str = extractFileText(filename); sentences = splitSentences(str);
View the first few sentences.
ans = 10x1 string "THE SONNETS" "by William Shakespeare" "I" "From fairest creatures we desire increase,..." "II" "When forty winters shall besiege thy brow,..." "How much more praise deserv'd thy beauty's use,..." "This were to be new made when thou art old,..." "III" "Look in thy glass and tell the face thou viewest..."
str — Input text
string scalar | character vector | scalar cell array containing a character vector
Input text, specified as a string scalar, a character vector, or a scalar cell array containing a character vector.
document — Input document
Input document, specified as a scalar
newStr — Output text
string array | character vector | cell array of character vectors
Output text, returned as a string array, character vector, or cell array of character
newStr have the same data
newDocuments — Output documents
Output documents, returned as a
If emoticons or emoji characters appear after a terminating punctuation character, then the function splits the sentence after the emoticons and emoji.
Introduced in R2018a