Struct LexiconIndex
pub struct LexiconIndex { /* private fields */ }Expand description
Index for querying the lexicon by features, sorts, and classes.
Implementations§
§impl LexiconIndex
impl LexiconIndex
pub fn new() -> LexiconIndex
pub fn new() -> LexiconIndex
Load and parse the lexicon from the embedded JSON file.
pub fn proper_nouns(&self) -> Vec<&NounEntry>
pub fn proper_nouns(&self) -> Vec<&NounEntry>
Get all nouns marked with the “Proper” feature (names).
pub fn common_nouns(&self) -> Vec<&NounEntry>
pub fn common_nouns(&self) -> Vec<&NounEntry>
Get all nouns NOT marked as proper (common nouns).
pub fn nouns_with_feature(&self, feature: &str) -> Vec<&NounEntry>
pub fn nouns_with_feature(&self, feature: &str) -> Vec<&NounEntry>
Get all nouns with a specific feature (case-insensitive).
pub fn nouns_with_sort(&self, sort: &str) -> Vec<&NounEntry>
pub fn nouns_with_sort(&self, sort: &str) -> Vec<&NounEntry>
Get all nouns with a specific semantic sort (case-insensitive).
pub fn verbs_with_feature(&self, feature: &str) -> Vec<&VerbEntry>
pub fn verbs_with_feature(&self, feature: &str) -> Vec<&VerbEntry>
Get all verbs with a specific feature (case-insensitive).
pub fn verbs_with_class(&self, class: &str) -> Vec<&VerbEntry>
pub fn verbs_with_class(&self, class: &str) -> Vec<&VerbEntry>
Get all verbs with a specific Vendler class (case-insensitive).
pub fn intransitive_verbs(&self) -> Vec<&VerbEntry>
pub fn intransitive_verbs(&self) -> Vec<&VerbEntry>
Get all verbs that are intransitive (no Transitive/Ditransitive feature).
pub fn transitive_verbs(&self) -> Vec<&VerbEntry>
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).
pub fn adjectives_with_feature(&self, feature: &str) -> Vec<&AdjectiveEntry>
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.
pub fn intersective_adjectives(&self) -> Vec<&AdjectiveEntry>
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").
pub fn random_proper_noun(&self, rng: &mut impl Rng) -> Option<&NounEntry>
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.
pub fn random_common_noun(&self, rng: &mut impl Rng) -> Option<&NounEntry>
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.
pub fn random_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>
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.
pub fn random_intransitive_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>
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.
pub fn random_transitive_verb(&self, rng: &mut impl Rng) -> Option<&VerbEntry>
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.
pub fn random_adjective(&self, rng: &mut impl Rng) -> Option<&AdjectiveEntry>
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.
pub fn random_intersective_adjective(
&self,
rng: &mut impl Rng,
) -> Option<&AdjectiveEntry>
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§
§impl Default for LexiconIndex
Creates a LexiconIndex by loading and parsing the embedded lexicon JSON.
impl Default for LexiconIndex
Creates a LexiconIndex by loading and parsing the embedded lexicon JSON.
Equivalent to calling LexiconIndex::new().