Main Content

addDependencyDetails

Add grammatical dependency details to documents

Since R2022b

    Description

    UseaddDependencyDetailsto add grammatical dependency details to documents.

    The function requires Deep Learning Toolbox™ and the Text Analytics Toolbox™ ModelUDify数据support package. The function supports English, Japanese, German, and Korean text.

    example

    updatedDocuments= addDependencyDetails(documents)adds grammatical dependency details todocumentsand updates the token details. To get the dependency details fromupdatedDocuments, usetokenDetails.

    Examples

    collapse all

    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. TheaddDependencyDetailsfunction requires the Text Analytics Toolbox™ Model forUDify Datasupport 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 thetokenDetailsfunction. TheHeadandDependencyvariables 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 tableToken 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

    collapse all

    Input documents, specified as atokenizedDocumentarray.

    Output Arguments

    collapse all

    Updated documents, returned as atokenizedDocumentarray. To get the token details fromupdatedDocuments, usetokenDetails.

    Algorithms

    collapse all

    Grammatical Dependency Parsing

    TheaddDependencyDetailsfunction adds grammatical dependency tags to the table returned by thetokenDetailsfunction. 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 modifier

    • advmod— adverbial modifier

    • amod— adjectival modifier

    • appos— appositional modifier

    • aux— auxiliary

    • case— case marking

    • cc— coordinating conjunction

    • ccomp— clausal complement

    • clf— classifier

    • compound— compound

    • conj— conjunct

    • cop— copula

    • csubj— clausal subject

    • dep— unspecified dependency

    • det— determiner

    • discourse— discourse element

    • dislocated— dislocated elements

    • expl— expletive

    • fixed— fixed multiword expression

    • flat— flat multiword expression

    • goeswith— goes with

    • iobj— indirect object

    • list— list

    • mark— marker

    • nmod— nominal modifier

    • nsubj— nominal subject

    • nummod— numeric modifier

    • obj— object

    • obl— oblique nominal

    • orphan— orphan

    • parataxis— parataxis

    • punct— punctuation

    • reparandum— overridden disfluency

    • root— root

    • vocative— vocative

    • xcomp— open clausal complement

    References

    [1] Universal Dependency Relationshttps://universaldependencies.org/u/dep/index.html.

    Version History

    Introduced in R2022b