Nasty.AST.Clause (Nasty v0.3.0)
View SourceClause 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
Functions
Checks if a clause is dependent (requires main clause).
Checks if a clause is independent (can stand alone).
Creates a new clause.
Types
@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
@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
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
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
@spec new( clause_type(), Nasty.AST.VerbPhrase.t(), Nasty.AST.Node.language(), Nasty.AST.Node.span(), keyword() ) :: t()
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