Skip to main content

NounParsing

Trait NounParsing 

Source
pub trait NounParsing<'a, 'ctx, 'int> {
    // Required methods
    fn parse_noun_phrase(
        &mut self,
        greedy: bool,
    ) -> Result<NounPhrase<'a>, ParseError>;
    fn parse_noun_phrase_for_relative(
        &mut self,
    ) -> Result<NounPhrase<'a>, ParseError>;
    fn noun_phrase_to_term(&self, np: &NounPhrase<'a>) -> Term<'a>;
    fn check_possessive(&self) -> bool;
    fn check_of_preposition(&self) -> bool;
    fn check_proper_name_or_label(&self) -> bool;
    fn peek_reduced_object_relative(&self) -> bool;
    fn peek_definite_reduced_relative_object(&self) -> bool;
    fn check_possessive_pronoun(&self) -> bool;
    fn numeric_label_head(
        &mut self,
        n: i64,
        head: Symbol,
        definiteness: Option<Definiteness>,
        measure_restrictors: &mut Vec<&'a LogicExpr<'a>>,
    ) -> Symbol;
    fn consume_label_head_noun_first(&mut self) -> Result<Symbol, ParseError>;
}
Expand description

Trait for parsing noun phrases.

Provides methods for parsing determiners, adjectives, possessives, and converting noun phrases to first-order terms.

Required Methods§

Source

fn parse_noun_phrase( &mut self, greedy: bool, ) -> Result<NounPhrase<'a>, ParseError>

Parses a full noun phrase with optional greedy PP attachment.

Source

fn parse_noun_phrase_for_relative( &mut self, ) -> Result<NounPhrase<'a>, ParseError>

Parses a noun phrase suitable for relative clause antecedent.

Source

fn noun_phrase_to_term(&self, np: &NounPhrase<'a>) -> Term<'a>

Converts a parsed noun phrase to a first-order term.

Source

fn check_possessive(&self) -> bool

Checks for possessive marker (’s).

Source

fn check_of_preposition(&self) -> bool

Checks for “of” preposition (possessive or partitive).

Source

fn check_proper_name_or_label(&self) -> bool

Checks for proper name or label (capitalized).

Source

fn peek_reduced_object_relative(&self) -> bool

Whether the cursor opens an object-gap reduced relative (subject + transitive verb + empty object slot), e.g. “Tara won” in “the prize Tara won”.

Source

fn peek_definite_reduced_relative_object(&self) -> bool

Whether the cursor sits on a DEFINITE article that opens a noun phrase whose head is modified by a reduced object relative (“the friend Simon went with”, “the waterfall Derrick photographed”). Used by the object-NP dispatcher to route such an object through the full parse_noun_phrase machinery instead of pre-consuming the article (which would hide the relative).

Source

fn check_possessive_pronoun(&self) -> bool

Checks for possessive pronoun (his, her, its, their).

Source

fn numeric_label_head( &mut self, n: i64, head: Symbol, definiteness: Option<Definiteness>, measure_restrictors: &mut Vec<&'a LogicExpr<'a>>, ) -> Symbol

Resolves a numeric LABEL (“the 2003 holiday”, “the 1850 stamp”): returns the head symbol, FUSED (2003_holiday) by default, but UN-FUSED to the bare head plus a category relation restrictor (pushed onto measure_restrictors) when n names a DRS-declared item whose category maps to a preposition.

Source

fn consume_label_head_noun_first(&mut self) -> Result<Symbol, ParseError>

Consume a numeric-label HEAD preferring the NOUN reading of a verb-ambiguous word, so the fused symbol matches the noun-compound form (“the 2001 trip” → 2001_trip, not the verb lemma 2001_Trip). A verb-only head (“stamp”) has no noun reading and keeps its lemma; a plain noun (“holiday”) is already the noun. (The un-fused predicate is capitalized downstream regardless.)

Implementors§

Source§

impl<'a, 'ctx, 'int> NounParsing<'a, 'ctx, 'int> for Parser<'a, 'ctx, 'int>