Nasty.AST.Dependency (Nasty v0.3.0)
View SourceDependency arc representing a grammatical relation between tokens.
Dependencies follow the Universal Dependencies (UD) annotation scheme, providing a cross-linguistically consistent representation of grammatical structure.
Reference: https://universaldependencies.org/u/dep/
Summary
Functions
Checks if relation is a core argument (subject, object, clausal complement).
Checks if relation is a function word (determiner, case marker, auxiliary).
Checks if relation is a modifier (adjectival, adverbial, nominal).
Creates a new dependency arc.
Returns all supported Universal Dependencies relation types.
Types
@type relation_type() ::
:nsubj
| :obj
| :iobj
| :csubj
| :ccomp
| :xcomp
| :obl
| :vocative
| :expl
| :dislocated
| :nmod
| :appos
| :nummod
| :case
| :det
| :clf
| :compound
| :flat
| :fixed
| :list
| :parataxis
| :conj
| :cc
| :amod
| :advmod
| :aux
| :cop
| :mark
| :acl
| :advcl
| :discourse
| :punct
| :root
| :dep
Universal Dependencies relation types.
Core arguments
:nsubj- Nominal subject:obj- Object:iobj- Indirect object:csubj- Clausal subject:ccomp- Clausal complement:xcomp- Open clausal complement
Non-core dependents
:obl- Oblique nominal:vocative- Vocative:expl- Expletive:dislocated- Dislocated elements
Nominal dependents
:nmod- Nominal modifier:appos- Appositional modifier:nummod- Numeric modifier
Case-marking & function words
:case- Case marking:det- Determiner:clf- Classifier
Compounding & MWE
:compound- Compound:flat- Flat multiword expression:fixed- Fixed multiword expression
Loose joining relations
:list- List:parataxis- Parataxis
Coordination
:conj- Conjunct:cc- Coordinating conjunction
Modifier words
:amod- Adjectival modifier:advmod- Adverb modifier:aux- Auxiliary:cop- Copula:mark- Marker
Other
:acl- Clausal modifier of noun (adjectival clause):advcl- Adverbial clause modifier:discourse- Discourse element:punct- Punctuation:root- Root of the sentence:dep- Unspecified dependency
Reference: https://universaldependencies.org/u/dep/
@type t() :: %Nasty.AST.Dependency{ dependent: Nasty.AST.Token.t(), head: Nasty.AST.Token.t(), relation: relation_type(), span: Nasty.AST.Node.span() }
Functions
Checks if relation is a core argument (subject, object, clausal complement).
Examples
iex> dep = %Nasty.AST.Dependency{relation: :nsubj, ...}
iex> Nasty.AST.Dependency.core_argument?(dep)
true
iex> dep = %Nasty.AST.Dependency{relation: :amod, ...}
iex> Nasty.AST.Dependency.core_argument?(dep)
false
Checks if relation is a function word (determiner, case marker, auxiliary).
Examples
iex> dep = %Nasty.AST.Dependency{relation: :det, ...}
iex> Nasty.AST.Dependency.function_word?(dep)
true
Checks if relation is a modifier (adjectival, adverbial, nominal).
Examples
iex> dep = %Nasty.AST.Dependency{relation: :amod, ...}
iex> Nasty.AST.Dependency.modifier?(dep)
true
@spec new( relation_type(), Nasty.AST.Token.t(), Nasty.AST.Token.t(), Nasty.AST.Node.span() ) :: t()
Creates a new dependency arc.
Examples
iex> span = Nasty.AST.Node.make_span({1, 0}, 0, {1, 10}, 10)
iex> head = %Nasty.AST.Token{text: "sat", pos_tag: :verb, language: :en, span: span}
iex> dep = %Nasty.AST.Token{text: "cat", pos_tag: :noun, language: :en, span: span}
iex> arc = Nasty.AST.Dependency.new(:nsubj, head, dep, span)
iex> arc.relation
:nsubj
@spec relation_types() :: [relation_type()]
Returns all supported Universal Dependencies relation types.