Skip to content

Dependency Parser

The relationship between words or tokens in a sentence can be used to analyze the meaning of the sentence. This relationship can be obtained by using the Dependency Parser. On the Dependency Parser, each token in a sentence will be associated with other tokens in the sentence based on its syntactic and semantic functions. This relationship is represented by a directional arc from the parent token (head) to the modifier token, indicating that the parent token is described by the modifier token.

The end result of Dependency Parser is a dependency tree showing the sentence structure based on the function of each token against the other tokens.

Illustration

Dependency Parser

For example in the sentence Saya makan nasi putih :

  • Saya identifies the subject of the predicate makan , so the dependency relation nsubj linked from makan to saya

  • Nasi identifies the object of the predicate makan, so the dependency relation obj linked from makan to nasi.

  • Putih denotes modifier of the noun nasi, so the dependency relation amod linked from nasi to putih.

  • Full stop (.) denotes the end of intonation of the sentence whose main predicate is makan, so the dependency relation punct linked from makan to “.”

Request Method

POST

Request URL

1
https://api.prosa.ai/v2/text/dependency

Request Header

Key Data Type Description Value
Content-Type string Media type of the body sent to the API. Only Support 'application/json' application/json
x-api-key string API Key Acquired from Prosa API Console [YOUR_API_KEY]

Request Body

The request body accepts the following parameter(s) in JSON format.

Parameter Data Type Description Auto Required
text string text to be processed (can only process one sentence) True

Granularity Enums

Part-of-speech tags granularity.

Granularity Description
coarse 16 classes based on universal dependencies pos tags.
fine_graned 28 classed based on INACL(Indonesia Association of Computational Linguistics) convention.

Example

Sample Request (JSON)

1
2
3
{
    "text":"Aku mencintai bahasa Indonesia karena aku orang Indonesia."
}

Sample Response (JSON)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{
    "parsed": {
        "tokens": [
            {
                "token": "Aku",
                "id": 1,
                "parent_id": 2,
                "parent_rel": "nsubj",
                "pos": "PRN"
            },
            {
                "token": "mencintai",
                "id": 2,
                "parent_id": 0,
                "parent_rel": "root",
                "pos": "VBT"
            },
            {
                "token": "bahasa",
                "id": 3,
                "parent_id": 2,
                "parent_rel": "obj",
                "pos": "NNO"
            },
            {
                "token": "Indonesia",
                "id": 4,
                "parent_id": 3,
                "parent_rel": "nmod",
                "pos": "NNP"
            },
            {
                "token": "karena",
                "id": 5,
                "parent_id": 7,
                "parent_rel": "mark",
                "pos": "CSN"
            },
            {
                "token": "aku",
                "id": 6,
                "parent_id": 7,
                "parent_rel": "nsubj",
                "pos": "PRN"
            },
            {
                "token": "orang",
                "id": 7,
                "parent_id": 2,
                "parent_rel": "advcl",
                "pos": "NNO"
            },
            {
                "token": "Indonesia",
                "id": 8,
                "parent_id": 7,
                "parent_rel": "nmod",
                "pos": "NNP"
            },
            {
                "token": ".",
                "id": 9,
                "parent_id": 2,
                "parent_rel": "punct",
                "pos": "PUN"
            }
        ],
        "sentence": "Aku mencintai bahasa Indonesia karena aku orang Indonesia."
    },
    "displacy": {
        "arcs": [
            {
                "dir": "left",
                "start": 0,
                "end": 1,
                "label": "nsubj"
            },
            {
                "dir": "right",
                "start": 1,
                "end": 2,
                "label": "obj"
            },
            {
                "dir": "right",
                "start": 2,
                "end": 3,
                "label": "nmod"
            },
            {
                "dir": "left",
                "start": 4,
                "end": 6,
                "label": "mark"
            },
            {
                "dir": "left",
                "start": 5,
                "end": 6,
                "label": "nsubj"
            },
            {
                "dir": "right",
                "start": 1,
                "end": 6,
                "label": "advcl"
            },
            {
                "dir": "right",
                "start": 6,
                "end": 7,
                "label": "nmod"
            },
            {
                "dir": "right",
                "start": 1,
                "end": 8,
                "label": "punct"
            }
        ],
        "words": [
            {
                "tag": "PRN",
                "text": "Aku"
            },
            {
                "tag": "VBT",
                "text": "mencintai"
            },
            {
                "tag": "NNO",
                "text": "bahasa"
            },
            {
                "tag": "NNP",
                "text": "Indonesia"
            },
            {
                "tag": "CSN",
                "text": "karena"
            },
            {
                "tag": "PRN",
                "text": "aku"
            },
            {
                "tag": "NNO",
                "text": "orang"
            },
            {
                "tag": "NNP",
                "text": "Indonesia"
            },
            {
                "tag": "PUN",
                "text": "."
            }
        ]
    }
}

Dependency Relations

Based on Universal Dependencies V2 Conventions, with changes compatible to Indonesian language

Name Code Example Description
Adjectival Clause acl tempat berkumpul semua orang (tempat -> berkumpul) Finite and non-finite clauses that modify a nominal
Relative Adjectival Clause acl:relcl orang yang pintar (orang -> pintar) Finite and non-finite clauses that modify a nominal that are connected with a relative pronoun (INACL PRR)
Adverbial Clause Modifier advcl Dia pergi ke pasar saat rumahnya kebakaran. (pergi -> kebakaran) Clauses which modify a verb or other predicate (adjective, etc.), as a modifier, not as a core complement
Adverbial Modifier advmod sangat menyakitkan (menyakitkan -> sangat) Non-clausal adverbs or adverbial phrases that serve to modify a predicate or a modifier word
Adjectival Modifier amod orang lemah (orang -> lemah) Adjectival phrases that serve to modify the meaning of the noun
Appositional Modifier appos dokter terkenal dari Pariaman, Achtung (dokter -> Achtung) Nominals immediately following the first noun that serves to define, modify, name, or describe that noun
Auxiliary aux telah pergi (pergi -> telah) Function words associated with a verbal predicate that expresses categories such as tense, mood, aspect, voice or evidentiality
Case Marking case dari Padang (Padang -> dari) Case-marking elements which are treated as a separate syntactic word (only prepositions in Indonesian)
Coordinating Conjunction cc saya dan dia (dia -> dan) Coordinating conjunctions connected to its next conjunct in a conjunction construction
Clausal Complement ccomp Dia mengatakan kamu suka berenang (mengatakan -> suka) Dependent clauses which are core arguments of the main phrase (function like an object of the predicate)
Classifier clf lima orang pahlawan (lima -> orang) Words which accompany a noun in certain grammatical contexts (in Indonesian only for accompanying numerals to explain the type of the nominal)
Compound compound makan angin (makan -> angin) Multiword expressions that differ in meaning when treated as separate instance and are neither a fixed grammatical phrase (fixed) nor a rootless phrase (flat) like a person's name
Conjunct conj Saya membeli apel dan jeruk. (apel -> jeruk) Connects two elements connected by a coordinating conjunction
Copula cop Saya adalah orang yang bahagia. (orang -> adalah) Function words used to link a subject to a nonverbal predicate.
Clausal Subject csubj Merokok membunuhmu. (membunuh -> Merokok) Clausal syntactic subject of a clause, i.e., the subject is itself a clause
Determiner det orang ini (orang -> ini) Determiners connected to a nominal
Discourse Element discourse Wah, dia sangat pintar! (pintar -> Wah) Interjections and other discourse particles and elements (which are not clearly linked to the structure of the sentence, except in an expressive way)
Fixed Multiword Expression fixed oleh karena itu (oleh -> karena) Multiword expressions that cannot be modified in any other word and function as fixed grammatical expressions
Flat Multiword Expression flat Arief Rahman Hakim (Arief -> Rahman, Arief -> Hakim) Multiword expressions that have no clear internal syntactic structure and no clear evidence that one of the words is the syntactic head (e.g. proper nominals)
Goes With goeswith Tugas itu di kerja kan Adi. (di -> kerja, di -> kan) Links two or more parts of a word that are separated in text that is not well edited
Indirect Object iobj Dia memberi saya kenaikan gaji. (memberi -> saya) Nominal phrases that are a core argument of the verb but is not its subject or (direct) object
List list Arief R. Telp.: 08xxxxxxxxxxx, e-mail: ariefr@x.com (Arief -> Telp., Arief -> e-mail) Links chains of comparable items
Marker mark Dia sakit karena kehujanan. (kehujanan -> karena) Words marking a clause as subordinate to another clause
Nominal Modifier nmod orang dari Cina (orang -> Cina) Nominal dependents of another noun or noun phrase and functionally corresponds to an attribute
Possessive Nominal Modifier nmod:poss buku saya (buku -> saya) Nominal dependents of another noun or noun phrase and functionally corresponds to a genitive complement
Nominal Subject nsubj Saya bukan orang netral. (orang -> Saya) Nominal that becomes the syntactic subject and the proto-agent of a clause
Numeric Modifier nummod tiga buku (buku -> tiga) Number phrases that serve to modify the meaning of the noun with a quantity
Object obj Saya suka bawang. (suka -> bawang) Typically the noun phrases that denote the entity acted upon or which undergo a change of state or motion (the proto-patient)
Oblique Nominal obl Dia pergi ke pasar. (pergi -> pasar) Nominals (noun, pronoun, noun phrase) functioning as a non-core (oblique) argument or adjunct
Orphan orphan Saya membeli kopi dan dia jus. (dia -> jus) Used in cases of head ellipsis where simple promotion would result in unnatural and misleading dependency relation
Parataxis parataxis Bank X tidak bagus, saya coba transaksi berkali-kali tapi selalu gagal. (bagus -> coba) Relation between a word (often the main predicate of a sentence) and other elements, such as a sentential parenthetical or a clause after a “:” or a “;”, placed side by side without any explicit coordination, subordination, or argument relation with the head word
Punctuation punct Saya buta. (buta -> .) Punctuation
Vocative vocative Randi, buka pintu itu! (buka -> Randi) Marks a dialogue participant addressed in a text
Open Clausal Complement xcomp Saya pergi memasak (pergi -> memasak) Predicatives or clausal complements without its own subject

Free trial

Are you interested in our API? Click the button below and get your free trial now.

try now

Version History

Below is the version history for our dependency parser API. Note that UAS is the accuracy metric that counts the number of correct dependency relations predicted, while LAS counts the number of correct dependency relations AND correct dependency labels predicted.

Version UAS LAS Test Data
1.0 80.77% 69.12% 392 sentences (7,361 tokens)

Questions?

We do our best to make this documentation clear and user friendly, but if you have unanswered questions, please send email to support@prosa.ai.