Expand description
Runtime JSON-based lexicon loading (requires dynamic-lexicon feature).
This module provides dynamic lexicon loading as an alternative to compile-time
code generation. It defines its own entry types (runtime::VerbEntry, etc.)
for JSON deserialization, distinct from the compile-time types in types.
Runtime lexicon loading for development builds.
This module provides dynamic JSON-based lexicon loading as an alternative
to compile-time code generation. Enable with the dynamic-lexicon feature.
§Architecture
The runtime lexicon trades compile-time safety for faster iteration during
development. Instead of generating Rust code from lexicon.json at build time,
this module embeds the JSON and parses it once at runtime when LexiconIndex::new()
is called.
§When to Use
- Development: Use
dynamic-lexiconfor faster edit-compile cycles when modifying the lexicon. - Production: Disable this feature for compile-time validation and slightly faster startup.
§JSON Format
The lexicon file must contain three top-level arrays:
nouns: Array ofNounEntryobjects withlemma, optionalforms,features, andsortverbs: Array ofVerbEntryobjects withlemma,class, optionalforms, andfeaturesadjectives: Array ofAdjectiveEntryobjects withlemma,regular, andfeatures
§Example
use logicaffeine_lexicon::runtime::LexiconIndex;
let lexicon = LexiconIndex::new();
let proper_nouns = lexicon.proper_nouns();
assert!(!proper_nouns.is_empty());§Type Disambiguation
This module defines its own VerbEntry, NounEntry, and AdjectiveEntry types
for JSON deserialization. These are distinct from crate::VerbEntry and other types
in the parent crate::types module, which are used for compile-time generated lookups.
Structs§
- Adjective
Entry - An adjective entry from the lexicon database.
- Lexicon
Data - Deserialized lexicon data from lexicon.json.
- Lexicon
Index - Index for querying the lexicon by features, sorts, and classes.
- Noun
Entry - A noun entry from the lexicon database.
- Verb
Entry - A verb entry from the lexicon database.
Functions§
- gerund
- Computes the gerund (present participle) form of a verb.
- past_
tense - Computes the past tense form of a verb.
- pluralize
- Computes the plural form of a noun.
- present_
3s - Computes the third-person singular present tense form of a verb.