({{, (RefLink[TextStructure, paclet:ref/TextStructure])["text"] 
generates a nested collection of (RefLink[TextElement, paclet:ref/TextElement]) objects representing the grammatical structure of natural language text.}, {, (RefLink[TextStructure, paclet:ref/TextStructure])["text",form]
generates a representation of the type specified by form of the grammatical structure of text.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[TextStructure, paclet:ref/TextStructure])[{(Subscript[text, 1]),(Subscript[text, 2]),…},…] yields a list with the respective results for (Subscript[text, i]).

Possible types of text structure include:

The following option can be given:

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Display the grammatical structure of a sentence:

TextStructure["The cat sat on the mat."]

Display parts of speech tags:

TextStructure["The cat sat on the mat.","PartsOfSpeech"]

OpenersExampleSection1(Spacer1)Scope  (6)

Display the constituent tree of a sentence:

TextStructure["Time flies like an arrow.","ConstituentTree"]

Return the constituent tree as a graph:

TextStructure["The cat sat on the mat.","ConstituentGraphs"]

Return the constituent tree as a string of nested parentheses:

TextStructure["The cat sat on the mat.","ConstituentStrings"]

Return the grammatical dependencies as a graph:

TextStructure["The cat sat on the mat.","DependencyGraphs"]

Display the dependency tree as a string of nested brackets:

TextStructure["The cat sat on the mat.","DependencyStrings"]

Display the grammatical structure of several sentences at once:

TextStructure["The cat sat on the mat. The bat and a rat sat on a mat."]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)PerformanceGoal  (1)

Faster parts of speech tagging can be achieved by using (RefLink[PerformanceGoal, paclet:ref/PerformanceGoal])->"Speed":

RepeatedTiming[TextStructure["The cat sat on the mat. The bat and a rat sat on a mat.","PartsOfSpeech"]]

RepeatedTiming[TextStructure["The cat sat on the mat. The bat and a rat sat on a mat.","PartsOfSpeech",PerformanceGoal->"Speed"]]

OpenersExampleSection3(Spacer1)Applications  (1)

Get the text content of a Wikipedia page using (RefLink[WikipediaData, paclet:ref/WikipediaData]):

wiki=WikipediaData["monkey"];

StringLength[wiki]

Extract the first paragraph using (RefLink[TextCases, paclet:ref/TextCases]):

paragraph = First@TextCases[wiki, "Paragraph",1]

Use (RefLink[TextStructure, paclet:ref/TextStructure]) to visualize the grammatical structure of this paragraph:

TextStructure[paragraph]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TextElement, paclet:ref/TextElement])  ▪  (RefLink[TextContents, paclet:ref/TextContents])  ▪  (RefLink[TextCases, paclet:ref/TextCases])  ▪  (RefLink[TextWords, paclet:ref/TextWords])  ▪  (RefLink[TextSentences, paclet:ref/TextSentences])  ▪  (RefLink[PartOfSpeech, paclet:ref/PartOfSpeech])  ▪  (RefLink[WordData, paclet:ref/WordData])  ▪  (RefLink[GrammarRules, paclet:ref/GrammarRules])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Text Manipulation, paclet:guide/ProcessingTextualData])}, {▪(RefLinkPlain[Text Analysis, paclet:guide/TextAnalysis])}, {▪(RefLinkPlain[Machine Learning, paclet:guide/MachineLearning])}, {▪(RefLinkPlain[Linguistic Data, paclet:guide/LinguisticData])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/35-natural-language-understanding.html])(WebLink[: Natural Language Understanding, https://www.wolfram.com/language/elementary-introduction/35-natural-language-understanding.html])}})}})