sentenceChart
Syntax
Description
sentenceChart(
plots the grammatical
dependency chart of sentence
)sentence
.
This syntax requires Deep Learning Toolbox™ and the Text Analytics Toolbox™ Model for UDify Data support package. If this support package is not installed, then the function provides a download link.
sentenceChart(
plots the grammatical dependency chart of the sentence using the dependency details encoded
by the tokens token
,head
,dependency
)token
, head details head
, and
dependency tags dependency
.
sentenceChart(
plots the grammatical
dependency chart of the sentence using the dependency details encoded by the token details
table tdetails
)tdetails
.
sentenceChart(___,
specifies additional options using one or more name-value arguments.Name=Value
)
sentenceChart(
creates
the sentence chart in the figure, panel, or tab specified by
parent
,___)parent
.
returns
the sc
= sentenceChart(___)DependencyChart
object. Use sc
to modify
properties of the sentence chart after creating it. For a list of properties, see DependencyChart Properties.
Examples
Create Sentence Chart
Create a string containing a single sentence.
sentence = "The quick brown fox jumped over the lazy dog.";
Visualize the dependency details in a sentence chart. Solid lines indicate dependencies and dotted lines indicate subtree labels.
figure sentenceChart(sentence)
Create Sentence Chart of Document
Create a tokenized document object containing a single sentence.
str = "The quick brown fox jumped over the lazy dog.";
sentence = tokenizedDocument(str)
document = tokenizedDocument: 10 tokens: The quick brown fox jumped over the lazy dog .
Visualize the dependency details in a sentence chart. Solid lines indicate dependencies and dotted lines indicate subtree labels.
figure sentenceChart(sentence)
Specify Sentence Chart Orientation
For long sentences, it can be easier to visualize the sentence structure if you orient the chart vertically.
Create a tokenized document object containing a single sentence.
str = "The particularly quick brown and white fox swiftly " + ... "jumped over the unbelievably lazy fluffy dog with big eyes."; sentence = tokenizedDocument(str)
document = tokenizedDocument: 19 tokens: The particularly quick brown and white fox swiftly jumped over the unbelivably lazy fluffy dog with big eyes .
Visualize the dependency details in a sentence chart. For readability, orient the sentence chart vertically by setting the Orientation
option to "vertical"
. Solid lines indicate dependencies and dotted lines indicate subtree labels.
figure
sentenceChart(sentence,Orientation="vertical")
Input Arguments
sentence
— Input sentence
tokenizedDocument
object | string scalar | character vector
Input sentence, specified as a tokenizedDocument
object, string
scalar, or character vector containing a single sentence.
token
— Sentence tokens
string vector | cell array of character vectors
Sentence tokens, specified as a string vector or a cell array of character vectors.
Data Types: string
| cell
head
— Token dependency heads
vector of nonnegative integers
Token dependency heads, specified as a vector of nonnegative integers, where
head(i)
is the index of the head token of
token(i)
and head(i)
is 0
for
the root token.
The dependency structure of head
must encode a tree.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
dependency
— Token dependency types
categorical vector | string vector | cell array of character vectors
Token dependency types, specified as a categorical vector, string vector, or cell array of character vectors. The object stores this input as a categorical vector.
Data Types: string
| cell
| categorical
tdetails
— Token details table
table
Token details table, specified as a table with the variables
Token
, Head
, and
Dependency
.
Entries in the
Token
variable correspond to the sentence tokens and must be string scalars or character vectors.Entries in the
Head
variable correspond to the token dependency heads and must be nonnegative integers, wheretdetails.Head(i)
is the index of the head token oftdetails.Token(i)
andtdetails.Head(i)
is0
for the root token. The dependency structure oftdetails.Head
must encode a tree.Entries in the
Dependency
variable correspond to the token dependency types and must be categorical values, string scalars, or character vectors.
Data Types: table
parent
— Parent
figure | panel | tab
Parent, specified as a figure, panel, or tab.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: sentenceChart(sentence,Orientation="vertical")
plots the
dependency chart of sentence
with tokens oriented
vertically.
The DependencyChart
properties listed here are only a subset. For a
complete list, see DependencyChart Properties.
Orientation
— Display orientation of sentence
"horizontal"
(default) | "vertical"
Display orientation of the sentence, specified as one of these values:
"horizontal"
— Display the tokens horizontally with the tree reading from top to bottom."vertical"
— Display the tokens vertically with the tree reading from left to right.
LineWidth
— Dependency line width
0.5
(default) | positive scalar
Dependency line width in points, specified as a positive scalar. One point equals 1/72 inch.
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
Note
If you do not specify LeaderLineWidth
, then the function
automatically sets LeaderLineWidth
to the value of
LineWidth
. To change the dependency line width only, set
LeaderLineWidth
to 0.5
.
LineColor
— Dependency line color
[0 0 0]
(default) | RGB triplet | string scalar | character vector
Dependency line color, specified as an RGB triplet or as a string scalar or character vector containing a color name.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
; for example,[0.4 0.6 0.7]
.A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Thus, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
LineStyle
— Dependency line style
"-"
(default) | "--"
| ":"
| "-."
| "none"
Dependency line style, specified as one of the options in this table.
Line Style | Description | Resulting Line |
---|---|---|
"-" | Solid line |
|
"--" | Dashed line |
|
":" | Dotted line |
|
"-." | Dash-dotted line |
|
"none" | No line | No line |
LeaderLineWidth
— Leader line width
LineWidth
(default) | positive scalar
Leader line width in points, specified as a positive scalar. One point equals 1/72 inch.
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
LeaderLineColor
— Leader line color
[0 0 0]
(default) | RGB triplet | string scalar | character vector
Leader line color, specified as an RGB triplet or as a string scalar or character vector containing a color name.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
; for example,[0.4 0.6 0.7]
.A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Thus, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
LeaderLineStyle
— Leader line style
":"
(default) | "-"
| "--"
| "-."
| "none"
Leader line style, specified as one of the options in this table.
Line Style | Description | Resulting Line |
---|---|---|
"-" | Solid line |
|
"--" | Dashed line |
|
":" | Dotted line |
|
"-." | Dash-dotted line |
|
"none" | No line | No line |
FontName
— Token and label font name
"Helvetica"
(default) | string scalar | character vector
Token and label font name, specified as a supported font name. For labels to display and print properly, you must choose a font that your system supports. The default font depends on the specific operating system and locale. For example, Windows® and Linux® systems in English localization use the Helvetica font by default.
Data Types: char
| string
FontSize
— Token font size
10
(default) | positive scalar
Token font size in points, specified as a positive scalar. One point equals 1/72 inch.
Note
If you do not specify the LabelFontSize
option, then the function automatically sets the LabelFontSize
option to 0.8*LineWidth
. To change the token font size only, set the LabelFontSize
option to 8
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
LabelFontName
— Label font name
"Helvetica"
(default) | string scalar | character vector
Label font name, specified as a supported font name. For labels to display and print properly, you must choose a font that your system supports. The default font depends on the specific operating system and locale. For example, Windows and Linux systems in English localization use the Helvetica font by default.
Data Types: char
| string
LabelFontSize
— Label font size
0.8*FontSize
(default) | positive scalar
Label font size in points, specified as a positive scalar. One point equals 1/72 inch.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
sc
— Grammatical dependency chart
DependencyChart
object
Grammatical dependency chart, returned as a DependencyChart
object.
You can modify the properties of a DependencyChart
after you create
it. For more information, see DependencyChart Properties.
Version History
Introduced in R2022b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)