Nasty.AST.Dependency (Nasty v0.3.0)

View Source

Dependency 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

Types

Universal Dependencies relation types.

t()

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

relation_type()

@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/

t()

@type t() :: %Nasty.AST.Dependency{
  dependent: Nasty.AST.Token.t(),
  head: Nasty.AST.Token.t(),
  relation: relation_type(),
  span: Nasty.AST.Node.span()
}

Functions

core_argument?(dependency)

@spec core_argument?(t()) :: boolean()

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

function_word?(dependency)

@spec function_word?(t()) :: boolean()

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

modifier?(dependency)

@spec modifier?(t()) :: boolean()

Checks if relation is a modifier (adjectival, adverbial, nominal).

Examples

iex> dep = %Nasty.AST.Dependency{relation: :amod, ...}
iex> Nasty.AST.Dependency.modifier?(dep)
true

new(relation, head, dependent, span)

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

relation_types()

@spec relation_types() :: [relation_type()]

Returns all supported Universal Dependencies relation types.