LexiconIndex

Struct LexiconIndex 

Source
pub struct LexiconIndex { /* private fields */ }
Expand description

Index for querying the lexicon by features, sorts, and classes.

Implementations§

Source§

impl LexiconIndex

Source

pub fn new() -> LexiconIndex

Load and parse the lexicon from the embedded JSON file.

Source

pub fn proper_nouns(&self) -> Vec<&NounEntry>

Get all nouns marked with the “Proper” feature (names).

Source

pub fn common_nouns(&self) -> Vec<&NounEntry>

Get all nouns NOT marked as proper (common nouns).

Source

pub fn nouns_with_feature(&self, feature: &str) -> Vec<&NounEntry>

Get all nouns with a specific feature (case-insensitive).

Source

pub fn nouns_with_sort(&self, sort: &str) -> Vec<&NounEntry>

Get all nouns with a specific semantic sort (case-insensitive).

Source

pub fn verbs_with_feature(&self, feature: &str) -> Vec<&VerbEntry>

Get all verbs with a specific feature (case-insensitive).

Source

pub fn verbs_with_class(&self, class: &str) -> Vec<&VerbEntry>

Get all verbs with a specific Vendler class (case-insensitive).

Source

pub fn intransitive_verbs(&self) -> Vec<&VerbEntry>

Get all verbs that are intransitive (no Transitive/Ditransitive feature).

Source

pub fn transitive_verbs(&self) -> Vec<&VerbEntry>

Returns all verbs that take a direct object.

Includes both transitive verbs (two-place predicates) and ditransitive verbs (three-place predicates). Verbs are matched if they have either the "Transitive" or "Ditransitive" feature (case-insensitive).

Source

pub fn adjectives_with_feature(&self, feature: &str) -> Vec<&AdjectiveEntry>

Returns all adjectives with a specific feature (case-insensitive).

Common features include "Intersective", "Subsective", "NonIntersective", and "Gradable". See crate::Feature for the full list.

Source

pub fn intersective_adjectives(&self) -> Vec<&AdjectiveEntry>

Returns all adjectives with intersective semantics.

Intersective adjectives combine with nouns via set intersection: “red ball” denotes things that are both red and balls. This is a convenience method equivalent to adjectives_with_feature("Intersective").

Source

pub fn random_proper_noun(&self, rng: &mut impl Rng) -> Option<&NounEntry>

Selects a random proper noun from the lexicon.

Returns None if the lexicon contains no proper nouns.

Source

pub fn random_common_noun(&self, rng: &mut impl Rng) -> Option<&NounEntry>

Selects a random common noun from the lexicon.

Returns None if the lexicon contains no common nouns.

Source

pub fn random_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>

Selects a random verb from the lexicon.

Returns None if the lexicon contains no verbs.

Source

pub fn random_intransitive_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>

Selects a random intransitive verb from the lexicon.

Returns None if the lexicon contains no intransitive verbs.

Source

pub fn random_transitive_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>

Selects a random transitive or ditransitive verb from the lexicon.

Returns None if the lexicon contains no transitive verbs.

Source

pub fn random_adjective(&self, rng: &mut impl Rng) -> Option<&AdjectiveEntry>

Selects a random adjective from the lexicon.

Returns None if the lexicon contains no adjectives.

Source

pub fn random_intersective_adjective( &self, rng: &mut impl Rng, ) -> Option<&AdjectiveEntry>

Selects a random intersective adjective from the lexicon.

Returns None if the lexicon contains no intersective adjectives.

Trait Implementations§

Source§

impl Default for LexiconIndex

Creates a LexiconIndex by loading and parsing the embedded lexicon JSON.

Equivalent to calling LexiconIndex::new().

Source§

fn default() -> LexiconIndex

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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