Main Content

addDependencyDetails

Add grammatical dependency details to documents

    Description

    Use addDependencyDetails to add grammatical dependency details to documents.

    The function supports English, Japanese, German, and Korean text.

    example

    updatedDocuments = addDependencyDetails(documents) adds grammatical dependency details to documents and updates the token details. To get the dependency details from updatedDocuments, use tokenDetails.

    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. 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)

    Figure contains an object of type textanalytics.chart.dependencychart.

    Input Arguments

    collapse all

    Input documents, specified as a tokenizedDocument array.

    Output Arguments

    collapse all

    Updated documents, returned as a tokenizedDocument array. To get the token details from updatedDocuments, use tokenDetails.

    Algorithms

    collapse all

    Grammatical Dependency Parsing

    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 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 Relations https://universaldependencies.org/u/dep/index.html.

    Version History

    Introduced in R2022b