unimorph_core/
lib.rs

1//! Core library for working with UniMorph morphological data.
2//!
3//! This crate provides types, storage, and query capabilities for UniMorph
4//! datasets. It is designed for high-performance lookups (conjugation/declension
5//! queries) while also supporting bulk export for ML pipelines.
6//!
7//! # Quick Start
8//!
9//! ```ignore
10//! use unimorph_core::{Repository, Store};
11//!
12//! #[tokio::main]
13//! async fn main() -> unimorph_core::Result<()> {
14//!     // Initialize repository (handles downloads and caching)
15//!     let repo = Repository::new()?;
16//!
17//!     // Ensure Italian dataset is available
18//!     repo.ensure("ita").await?;
19//!
20//!     // Open the store for queries
21//!     let store = repo.store()?;
22//!
23//!     // Look up all forms of "parlare"
24//!     for entry in store.inflect("ita", "parlare")? {
25//!         println!("{} -> {} ({})", entry.lemma, entry.form, entry.features);
26//!     }
27//!
28//!     // Reverse lookup: what lemmas produce "parlo"?
29//!     for entry in store.analyze("ita", "parlo")? {
30//!         println!("{} <- {} ({})", entry.form, entry.lemma, entry.features);
31//!     }
32//!     Ok(())
33//! }
34//! ```
35//!
36//! # Architecture
37//!
38//! - **SQLite backend**: All data stored in a single file at `~/.cache/unimorph/datasets.db`
39//! - **Pre-computed stats**: Aggregate statistics cached at import time
40//! - **Iterator-based queries**: Results stream from SQLite, won't OOM on large datasets
41//! - **Parquet export**: For users who need DataFrame integration
42
43pub mod error;
44pub mod export;
45pub mod query;
46pub mod repository;
47pub mod store;
48pub mod types;
49
50pub use error::{Error, Result};
51#[cfg(feature = "parquet")]
52pub use export::ParquetExportOptions;
53pub use query::QueryBuilder;
54pub use repository::{DownloadPhase, DownloadProgress, Repository};
55pub use store::Store;
56pub use types::{
57    CompressionFormat, DatasetStats, Entry, FeatureBundle, LangCode, MalformedEntry, ParseReport,
58};