This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

splitSentences

Split text into sentences

Syntax

newStr = splitSentences(str)

Description

example

newStr = splitSentences(str) splits str into an array of sentences.

Examples

collapse all

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.

sentences(1:10)
ans = 10x1 string array
    "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..."

Input Arguments

collapse all

Input text, specified as a string scalar, a character vector, or a scalar cell array containing a character vector.

Data Types: string | char | cell

Output Arguments

collapse all

Output text, returned as a string array, a character vector, or cell array of character vectors. str and newStr have the same data type.

Algorithms

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