Module runtime_lexicon

Module runtime_lexicon 

Source
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-lexicon for 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 of NounEntry objects with lemma, optional forms, features, and sort
  • verbs: Array of VerbEntry objects with lemma, class, optional forms, and features
  • adjectives: Array of AdjectiveEntry objects with lemma, regular, and features

§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§

AdjectiveEntry
An adjective entry from the lexicon database.
LexiconData
Deserialized lexicon data from lexicon.json.
LexiconIndex
Index for querying the lexicon by features, sorts, and classes.
NounEntry
A noun entry from the lexicon database.
VerbEntry
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.