logicaffeine_lexicon/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![warn(missing_docs)]
3
4//! English vocabulary types and runtime lexicon loading.
5//!
6//! This crate provides the core lexicon infrastructure for the logicaffeine
7//! English-to-First-Order-Logic transpiler. It defines the type system for
8//! representing linguistic knowledge and optionally provides runtime lexicon
9//! loading for faster development iteration.
10//!
11//! # Core Types
12//!
13//! The [`types`] module defines the fundamental linguistic categories:
14//!
15//! - **Verb classification**: [`VerbClass`] (Vendler's Aktionsart), [`Time`], [`Aspect`]
16//! - **Noun properties**: [`Number`], [`Gender`], [`Case`], [`Definiteness`]
17//! - **Semantic typing**: [`Sort`] (type hierarchy for entities)
18//! - **Lexical features**: [`Feature`] (27 grammatical and semantic properties)
19//! - **Metadata structs**: [`VerbMetadata`], [`NounMetadata`], [`AdjectiveMetadata`]
20//!
21//! # Architecture
22//!
23//! The lexicon supports two modes of operation:
24//!
25//! 1. **Compile-time** (default): The main `logicaffeine_language` crate generates
26//! Rust code from `lexicon.json` at build time, providing type-safe lookups
27//! with zero runtime parsing overhead.
28//!
29//! 2. **Runtime** (feature `dynamic-lexicon`): The [`runtime`] module loads and
30//! parses `lexicon.json` at runtime, trading compile-time safety for faster
31//! edit-compile cycles during development.
32//!
33//! # Feature Flags
34//!
35//! | Feature | Description |
36//! |---------|-------------|
37//! | `dynamic-lexicon` | Enable runtime JSON lexicon loading via the [`runtime`] module |
38//!
39//! # Example
40//!
41//! ```
42//! use logicaffeine_lexicon::{VerbClass, Feature, Sort};
43//!
44//! // Check verb aspectual properties
45//! let class = VerbClass::Activity;
46//! assert!(!class.is_stative());
47//! assert!(class.is_durative());
48//!
49//! // Parse features from strings
50//! let feature = Feature::from_str("Transitive");
51//! assert_eq!(feature, Some(Feature::Transitive));
52//!
53//! // Check sort compatibility
54//! assert!(Sort::Human.is_compatible_with(Sort::Animate));
55//! ```
56
57/// Lexicon type definitions for grammatical and semantic categories.
58pub mod types;
59pub use types::*;
60
61/// Runtime JSON-based lexicon loading (requires `dynamic-lexicon` feature).
62///
63/// This module provides dynamic lexicon loading as an alternative to compile-time
64/// code generation. It defines its own entry types (`runtime::VerbEntry`, etc.)
65/// for JSON deserialization, distinct from the compile-time types in [`types`].
66#[cfg(feature = "dynamic-lexicon")]
67#[cfg_attr(docsrs, doc(cfg(feature = "dynamic-lexicon")))]
68pub mod runtime;