addDependencyDetails - Add grammatical dependency details to documents - MATLAB (original) (raw)
Main Content
Add grammatical dependency details to documents
Since R2022b
Syntax
Description
Use addDependencyDetails
to add grammatical dependency details to documents.
The function requires Deep Learning Toolbox™ and the Text Analytics Toolbox™ Model for UDify Data support package. The function supports English, Japanese, German, and Korean text.
[updatedDocuments](#d126e1993) = addDependencyDetails([documents](#d126e1973))
adds grammatical dependency details to documents
and updates the token details. To get the dependency details from updatedDocuments
, usetokenDetails.
Examples
Create a tokenized document object containing a single sentence.
str = "The quick brown fox jumped over the lazy dog."; document = tokenizedDocument(str)
document = tokenizedDocument:
10 tokens: The quick brown fox jumped over the lazy dog .
Add grammatical dependency details to the document. The addDependencyDetails
function requires the Text Analytics Toolbox™ Model for UDify Data support package. If you do not have this support package installed, then the function provides a download link.
document = addDependencyDetails(document);
View the token details using the tokenDetails
function. The Head
and Dependency
variables of the table form a tree structure of the dependency details. For example, because the word "lazy" modifies the word "dog" in this sentence, the token details table lists the token number of "dog" as the head of the token "lazy".
details = tokenDetails(document)
details=10×8 table Token DocumentNumber SentenceNumber LineNumber Type Language Head Dependency ________ ______________ ______________ __________ ___________ ________ ____ __________
"The" 1 1 1 letters en 4 det
"quick" 1 1 1 letters en 4 amod
"brown" 1 1 1 letters en 4 amod
"fox" 1 1 1 letters en 5 nsubj
"jumped" 1 1 1 letters en 0 root
"over" 1 1 1 letters en 9 case
"the" 1 1 1 letters en 9 det
"lazy" 1 1 1 letters en 9 amod
"dog" 1 1 1 letters en 5 obl
"." 1 1 1 punctuation en 5 punct
Visualize the dependency details in a sentence chart. Solid lines indicate dependencies and dotted lines indicate subtree labels.
figure sentenceChart(document)
Input Arguments
Output Arguments
Algorithms
The addDependencyDetails
function adds grammatical dependency tags to the table returned by the tokenDetails function. The function tags each token with a categorical tag defined by Universal Dependencies. [1]
The dependency types listed here are only a subset. For a complete list of dependency types, including subtypes, see [1].
acl
— clausal modifier of noun (adnominal clause)advcl
— adverbial clause modifieradvmod
— adverbial modifieramod
— adjectival modifierappos
— appositional modifieraux
— auxiliarycase
— case markingcc
— coordinating conjunctionccomp
— clausal complementclf
— classifiercompound
— compoundconj
— conjunctcop
— copulacsubj
— clausal subjectdep
— unspecified dependencydet
— determinerdiscourse
— discourse elementdislocated
— dislocated elementsexpl
— expletivefixed
— fixed multiword expressionflat
— flat multiword expressiongoeswith
— goes withiobj
— indirect objectlist
— listmark
— markernmod
— nominal modifiernsubj
— nominal subjectnummod
— numeric modifierobj
— objectobl
— oblique nominalorphan
— orphanparataxis
— parataxispunct
— punctuationreparandum
— overridden disfluencyroot
— rootvocative
— vocativexcomp
— open clausal complement
References
Version History
Introduced in R2022b