Lexer

Struct Lexer 

Source
pub struct Lexer<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Lexer<'a>

Source

pub fn new(input: &str, interner: &'a mut Interner) -> Self

Creates a new lexer for the given input text.

The lexer will tokenize natural language text according to the lexicon database, performing morphological analysis and ambiguity resolution.

§Arguments
  • input - The natural language text to tokenize
  • interner - String interner for efficient symbol handling
§Example
use logicaffeine_language::lexer::Lexer;
use logicaffeine_base::Interner;

let mut interner = Interner::new();
let mut lexer = Lexer::new("Every cat sleeps.", &mut interner);
let tokens = lexer.tokenize();

assert_eq!(tokens.len(), 4); // Quantifier, Noun, Verb, Period
Source

pub fn tokenize(&mut self) -> Vec<Token>

Tokenizes the input text and returns a vector of Tokens.

Each token includes its type, the interned lexeme, and the source span for error reporting. Words are classified according to the lexicon database with priority-based ambiguity resolution.

§Returns

A vector of tokens representing the input. The final token is typically TokenType::Eof.

Source

pub fn is_collective_verb(lemma: &str) -> bool

Source

pub fn is_mixed_verb(lemma: &str) -> bool

Source

pub fn is_distributive_verb(lemma: &str) -> bool

Source

pub fn is_intensional_predicate(lemma: &str) -> bool

Source

pub fn is_opaque_verb(lemma: &str) -> bool

Source

pub fn is_ditransitive_verb(lemma: &str) -> bool

Source

pub fn is_subject_control_verb(lemma: &str) -> bool

Source

pub fn is_raising_verb(lemma: &str) -> bool

Source

pub fn is_object_control_verb(lemma: &str) -> bool

Source

pub fn is_weather_verb(lemma: &str) -> bool

Auto Trait Implementations§

§

impl<'a> Freeze for Lexer<'a>

§

impl<'a> RefUnwindSafe for Lexer<'a>

§

impl<'a> Send for Lexer<'a>

§

impl<'a> Sync for Lexer<'a>

§

impl<'a> Unpin for Lexer<'a>

§

impl<'a> !UnwindSafe for Lexer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V