-
See Also
- TextWords
- TextCases
- TextStructure
- StringSplit
-
- Text Contents
- Sentence
- Related Guides
TextSentences["string"]
gives a list of the runs of characters identified as sentences in string.
TextSentences["string",n]
gives the first n sentences in string.
TextSentences
TextSentences["string"]
gives a list of the runs of characters identified as sentences in string.
TextSentences["string",n]
gives the first n sentences in string.
Details
- White spaces and line breaks in between sentences in string are dropped by TextSentences.
- TextSentences[ContentObject[…]] gives sentences from the plain text contents of the ContentObject.
Examples
open all close allBasic Examples (2)
Segment a string into sentences:
TextSentences["This is a sentence. This is another sentence."]TextSentences["First sentence. Second sentence. Third sentence."]Get the first three sentences from a block of text:
TextSentences[ExampleData[{"Text", "DeclarationOfIndependence"}], 3]Scope (2)
TextSentences accounts for capitalization, spacing, and punctuation:
TextSentences["first sentence. second sentence. third sentence. fourth sentence."]TextSentences["this is the first sentence !!!! And this is the second one."]TextSentences["this is the first sentence :) And this is the second one."]Get the first four sentences in a ContentObject:
file = Export[FileNameJoin[{$TemporaryDirectory, "raven.txt"}], ExampleData[{"Text", "TheRaven"}]];
doc = ContentObject[File[file]]TextSentences[doc, 4]Properties & Relations (2)
TextSentences is equivalent to TextCases[…,"Sentence"]:
TextCases["Hi Michael J. Jordan. I am Michael I. Jordan.", "Sentence"]//TextElementTextSentences["Hi Michael J. Jordan. I am Michael I. Jordan."]//TextElementTextStructure splits texts into the same sentences:
TextStructure["Hi Michael J. Jordan. I am Michael I. Jordan.", "PartsOfSpeech"]Possible Issues (1)
Sentences may not be precisely identified in unstructured text:
TextSentences["Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore—
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
\"'Tis some visiter,\" I muttered, \"tapping at my chamber door—
Only this and nothing more.\""]Related Guides
Text
Wolfram Research (2015), TextSentences, Wolfram Language function, https://reference.wolfram.com/language/ref/TextSentences.html (updated 2016).
CMS
Wolfram Language. 2015. "TextSentences." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/TextSentences.html.
APA
Wolfram Language. (2015). TextSentences. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TextSentences.html
BibTeX
@misc{reference.wolfram_2026_textsentences, author="Wolfram Research", title="{TextSentences}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/TextSentences.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_textsentences, organization={Wolfram Research}, title={TextSentences}, year={2016}, url={https://reference.wolfram.com/language/ref/TextSentences.html}, note=[Accessed: 13-June-2026]}