Nasty.AST.Clause (Nasty v0.3.0)

View Source

Clause node representing a subject-predicate structure.

A clause is a grammatical unit containing a subject and a predicate (verb phrase). Clauses can be independent (main clauses) or dependent (subordinate clauses).

Summary

Types

Clause type classification.

t()

Functions

Checks if a clause is dependent (requires main clause).

Checks if a clause is independent (can stand alone).

Types

clause_type()

@type clause_type() :: :independent | :subordinate | :relative | :complement

Clause type classification.

  • :independent - Can stand alone as a sentence (main clause)
  • :subordinate - Dependent on another clause (adverbial, nominal, relative)
  • :relative - Modifies a noun (relative clause)
  • :complement - Completes the meaning of another clause

t()

@type t() :: %Nasty.AST.Clause{
  language: Nasty.AST.Node.language(),
  predicate: Nasty.AST.VerbPhrase.t(),
  span: Nasty.AST.Node.span(),
  subject: Nasty.AST.NounPhrase.t() | nil,
  subordinator: Nasty.AST.Token.t() | nil,
  type: clause_type()
}

Functions

dependent?(arg1)

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

Checks if a clause is dependent (requires main clause).

Examples

iex> clause = %Nasty.AST.Clause{type: :subordinate, predicate: vp, language: :en, span: span}
iex> Nasty.AST.Clause.dependent?(clause)
true

independent?(arg1)

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

Checks if a clause is independent (can stand alone).

Examples

iex> clause = %Nasty.AST.Clause{type: :independent, predicate: vp, language: :en, span: span}
iex> Nasty.AST.Clause.independent?(clause)
true

new(type, predicate, language, span, opts \\ [])

Creates a new clause.

Examples

iex> span = Nasty.AST.Node.make_span({1, 0}, 0, {1, 10}, 10)
iex> vp = %Nasty.AST.VerbPhrase{head: token, language: :en, span: span}
iex> clause = Nasty.AST.Clause.new(:independent, vp, :en, span)
iex> clause.type
:independent