pub trait ClauseParsing<'a, 'ctx, 'int> {
Show 28 methods
// Required methods
fn parse_sentence(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_conditional(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_either_or(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_disjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_conjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>;
fn extract_copular_subject(&self, expr: &'a LogicExpr<'a>) -> Option<Symbol>;
fn try_parse_copular_predicate(
&mut self,
subject: Symbol,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn parse_relative_clause(
&mut self,
gap_var: Symbol,
) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_gapped_clause(
&mut self,
borrowed_verb: Symbol,
) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_counterfactual_antecedent(
&mut self,
) -> Result<&'a LogicExpr<'a>, ParseError>;
fn parse_counterfactual_consequent(
&mut self,
) -> Result<&'a LogicExpr<'a>, ParseError>;
fn check_wh_word(&self) -> bool;
fn is_counterfactual_context(&self) -> bool;
fn is_complete_clause(&self, expr: &LogicExpr<'a>) -> bool;
fn extract_verb_from_expr(&self, expr: &LogicExpr<'a>) -> Option<Symbol>;
fn try_parse_imperative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn clause_has_later_finite_verb(&self, from: usize) -> bool;
fn is_reduced_relative_verb(&self, vp: usize) -> bool;
fn try_parse_cleft(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_exclamative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_optative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_correlative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_of_pair_xor(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_fronted_temporal_adjunct(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_inverted_conditional(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>;
fn try_parse_ellipsis(
&mut self,
) -> Option<Result<&'a LogicExpr<'a>, ParseError>>;
fn check_ellipsis_auxiliary(&self) -> bool;
fn check_ellipsis_terminator(&self) -> bool;
}Expand description
Trait for parsing clause-level structures.
Defines methods for parsing sentences, conditionals, conjunctions, and other clause-level constructs.
Required Methods§
Sourcefn parse_sentence(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_sentence(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses a complete sentence, handling imperatives, ellipsis, and questions.
Sourcefn parse_conditional(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_conditional(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “if P then Q” conditionals with DRS scope handling.
Sourcefn parse_either_or(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_either_or(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “either P or Q” exclusive disjunctions.
Sourcefn parse_disjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_disjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “P or Q” disjunctions.
Sourcefn parse_conjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_conjunction(&mut self) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “P and Q” conjunctions with scope coordination.
Sourcefn extract_copular_subject(&self, expr: &'a LogicExpr<'a>) -> Option<Symbol>
fn extract_copular_subject(&self, expr: &'a LogicExpr<'a>) -> Option<Symbol>
Extracts the subject of a copular predication, for non-parallel coordination.
Sourcefn try_parse_copular_predicate(
&mut self,
subject: Symbol,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_copular_predicate( &mut self, subject: Symbol, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Parses a bare copular-predicate remnant (“wealthy” / “a philanthropist”).
Sourcefn parse_relative_clause(
&mut self,
gap_var: Symbol,
) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_relative_clause( &mut self, gap_var: Symbol, ) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “who/that/which” relative clauses attaching to noun phrases.
Sourcefn parse_gapped_clause(
&mut self,
borrowed_verb: Symbol,
) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_gapped_clause( &mut self, borrowed_verb: Symbol, ) -> Result<&'a LogicExpr<'a>, ParseError>
Parses a clause with a gap filled by borrowed verb (for VP coordination).
Sourcefn parse_counterfactual_antecedent(
&mut self,
) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_counterfactual_antecedent( &mut self, ) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “if P were/had” counterfactual antecedent (subjunctive).
Sourcefn parse_counterfactual_consequent(
&mut self,
) -> Result<&'a LogicExpr<'a>, ParseError>
fn parse_counterfactual_consequent( &mut self, ) -> Result<&'a LogicExpr<'a>, ParseError>
Parses “Q would” counterfactual consequent.
Sourcefn check_wh_word(&self) -> bool
fn check_wh_word(&self) -> bool
Checks if current token is a wh-word (who, what, which, etc.).
Sourcefn is_counterfactual_context(&self) -> bool
fn is_counterfactual_context(&self) -> bool
Returns true if parsing a counterfactual context.
Sourcefn is_complete_clause(&self, expr: &LogicExpr<'a>) -> bool
fn is_complete_clause(&self, expr: &LogicExpr<'a>) -> bool
Returns true if expression is a complete clause.
Sourcefn extract_verb_from_expr(&self, expr: &LogicExpr<'a>) -> Option<Symbol>
fn extract_verb_from_expr(&self, expr: &LogicExpr<'a>) -> Option<Symbol>
Extracts the main verb from an expression.
Sourcefn try_parse_imperative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_imperative( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse an English imperative (“Close the door.”, “Don’t touch
that.”, “Let’s leave.”). Returns None (restoring position) when the input
is not verb-initial / not a hortative or negative command.
Sourcefn clause_has_later_finite_verb(&self, from: usize) -> bool
fn clause_has_later_finite_verb(&self, from: usize) -> bool
True if a finite verb (Verb/Auxiliary/copula/have/modal) appears at or after
from, before the clause terminator. Used to distinguish an imperative
(command verb is the only finite verb) from a declarative whose initial word
is a subject (“Set A has cardinality 5.”).
Sourcefn is_reduced_relative_verb(&self, vp: usize) -> bool
fn is_reduced_relative_verb(&self, vp: usize) -> bool
True when the verb at vp heads a reduced object relative (its overt subject
sits at vp - 1, the relativized head is the determiner-headed noun before
it), so it is NOT the clause’s main verb.
Sourcefn try_parse_cleft(&mut self) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_cleft(&mut self) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse an it-cleft “It was X who/that VP.” → focus on X plus
exhaustivity (only X did it). Returns None (restoring position) otherwise.
Sourcefn try_parse_exclamative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_exclamative( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse an exclamative “How tall she is!” / “What a fool he is!”
(how/what, no subject-aux inversion, “!”-terminated). Returns None otherwise.
Sourcefn try_parse_optative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_optative( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse an optative wish “May you prosper!”, “Long live the king!”,
“If only it were Friday!”. Returns None (restoring position) otherwise.
Sourcefn try_parse_correlative(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_correlative( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse correlative coordination “Neither X nor Y VP” / “Either X
or Y VP” — a shared predicate scoped over two subjects. None otherwise.
Sourcefn try_parse_of_pair_xor(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_of_pair_xor( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse “Of NP₁ and NP₂, one VP₁ and the other VP₂” →
(VP₁(NP₁) ∧ VP₂(NP₂)) ∨ (VP₁(NP₂) ∧ VP₂(NP₁)). Returns None otherwise.
Sourcefn try_parse_fronted_temporal_adjunct(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_fronted_temporal_adjunct( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse a sentence-initial temporal NP that FRAMES the clause
(“Every year Simon takes a holiday” → HAB), not its subject. None otherwise.
Sourcefn try_parse_inverted_conditional(
&mut self,
) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
fn try_parse_inverted_conditional( &mut self, ) -> Result<Option<&'a LogicExpr<'a>>, ParseError>
Attempts to parse an inverted conditional “Had/Were/Should SUBJECT …, …” by
un-inverting to the canonical “If SUBJECT aux …” form and reusing the conditional
parser. Handles multi-word subjects and Should-fronting. None otherwise.
Sourcefn try_parse_ellipsis(
&mut self,
) -> Option<Result<&'a LogicExpr<'a>, ParseError>>
fn try_parse_ellipsis( &mut self, ) -> Option<Result<&'a LogicExpr<'a>, ParseError>>
Attempts to parse VP ellipsis (“Mary did too”).
Sourcefn check_ellipsis_auxiliary(&self) -> bool
fn check_ellipsis_auxiliary(&self) -> bool
Checks for ellipsis auxiliary (did, does, can, etc.).
Sourcefn check_ellipsis_terminator(&self) -> bool
fn check_ellipsis_terminator(&self) -> bool
Checks for ellipsis terminator (too, also, as well).