TextStructure

TextStructure["text"]

generates a nested collection of TextElement objects representing the grammatical structure of natural language text.

TextStructure["text",form]

generates a representation of the type specified by form of the grammatical structure of text.

Details and Options

  • TextStructure[{text1,text2,},] yields a list with the respective results for texti.
  • Possible types of text structure include:
  • "ConstituentTree"nested text elements of phrase structure
    "ConstituentGraphs"graph of phrase structure
    "ConstituentStrings"string representing phrase structure
    "PartsOfSpeech"text elements tagging parts of speech
    "DependencyGraphs"graph of grammatical dependencies
    "DependencyStrings"string representing grammatical dependencies
  • The following option can be given:
  • PerformanceGoalAutomaticfavor algorithms with specific advantages

Examples

open allclose all

Basic Examples  (2)

Display the grammatical structure of a sentence:

Display parts of speech tags:

Scope  (6)

Display the constituent tree of a sentence:

Return the constituent tree as a graph:

Return the constituent tree as a string of nested parentheses:

Return the grammatical dependencies as a graph:

Display the dependency tree as a string of nested brackets:

Display the grammatical structure of several sentences at once:

Options  (1)

PerformanceGoal  (1)

Faster parts of speech tagging can be achieved by using PerformanceGoal->"Speed":

Applications  (1)

Get the text content of a Wikipedia page using WikipediaData:

Extract the first paragraph using TextCases:

Use TextStructure to visualize the grammatical structure of this paragraph:

Introduced in 2015
 (10.3)
 |
Updated in 2019
 (12.0)