Dependency Syntax Analysis

Introduction

This API is used to identify the dependencies between words in a sentence.

This API is free of charge and can be called twice per second.

URI

  • URI format
    POST /v1/{project_id}/nlp-fundamental/dependency-parser
  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request

Table 2 describes the request parameters.

Table 2 Request parameters

Parameter

Type

Mandatory

Description

text

String

Yes

Text to be analyzed. The text is encoded using UTF-8 and contains 1 to 32 characters.

lang

String

No

Supported language type. Currently, only Chinese is supported. The default value is zh.

Response

Table 3 describes the response parameters.

Table 3 Response parameters

Parameter

Type

Description

words

Array of words objects

Result of the dependency syntax analysis

For details, see Table 4.

error_code

String

Error code when the API fails to be called. For details, see Error Code.

The parameter is not included when the API call succeeds.

error_msg

String

Error message returned when the API fails to be called.

The parameter is not included when the API call succeeds.

Table 4 Data structure description of words field

Parameter

Type

Description

id

Integer

Word ID, starting from 1

word

String

Word content

pos

String

Part of speech. For details, see Table 6.

head_word_id

String

ID of a head sentence. If it is the root sentence, the default value is 0.

dependency_label

String

Dependency between a word and the head sentence. It uses the Chinese Open Dependency Treebank (CODT) dependency tag set.

For details, see Table 5.

Table 5 CODT relationship description

Relationship Label

Description

Example

Labeling Result

root

Sentence root

I love mom.

(Root -> love), where Root is a virtual word

sasubj-obj

Same subject and object

I have been studying and thinking about this question.

(Studying –> thinking)

sasubj

Same subject

I walk into the playground and play basketball.

(Walk into –> play)

dfsubj

Different subjects

This book is too expensive. I'm going to buy another one.

(Expensive –> going to)

subj

subject

I love mom.

(I <– love)

subj-in

subject inside a subject-predicate predicate

(Internal subject of the predicate in the subject-predicate structure)

He has ache in his head.

(Head <– ache)

obj

Object

I love mom.

(Love –> mom)

pred

Predicate

Order him to sweep the floor.

(Him –> sweep the floor)

att

Attribute modifier

State President

(State <- President)

adv

Adverbial modifier

Like very much.

(Very much <– like)

cmp

Complement modifier

Wash hands neatly.

(Wash –> neatly)

coo

Coordination construction

Flowers and applause.

(Flowers –> applause)

pobj

Preposition object

Read at home.

(At –> home)

iobj

Indirect-object

Give him a book.

(Give –> him)

de

de-construction

Text for analysis

(word-1 <– de)

adjct

Adjunct

Text for analysis

(word-1 -> adjunct)

app

Appellation

Hello, Miss.

(Miss <– hello)

exp

Explanation

Putin (Russian president)

(Putin –> president)

punc

Punctuation

I love mom.

(Love ->.)

frag

Fragment

You, me, China.

(You > me > China)

repet

Repetition

Have you had, had your dinner?

(Had –> had)

Example

  • Example request
    POST https://{endpoint}/v1/{project_id}/nlp-fundamental/dependency-parser
    
    Request Header: 
        Content-Type: application/json 
        X-Auth-Token: MIIFbwYJKoZIhvcNAQcCoIIFYDCCBVwCAQExDTALBglghkgBZQMEAgEwggNBgkqhkiG9... 
    Request Body:     { 
            "text": "Text for analysis",
            "lang":"zh" 
        }
  • Example response
    {
        "words": [
            {
                "id": 1,
                "word": "word-1",
                "pos": "NR",
                "head_word_id": 2,
                "dependency_label": "subj"
            },
            {
                "id": 2,
                "word": "word-2",
                "pos": "VV",
                "head_word_id": 0,
                "dependency_label": "root"
            },
            {
                "id": 3,
                "word": "word-3",
                "pos": "NN",
                "head_word_id": 2,
                "dependency_label": "obj"
            }
        ]
    }
    • Failed example response
      {
          "error_code": "NLP.0301",
          "error_message": "Missing parameters:text"
      }

Status Code

For details about status codes, see Status Code.

Error Code

For details about error codes, see Error Code.