Skip to main content

ukrainian_tn/
lib.rs

1//! Ukrainian text normalization, tokenization and sentence splitting.
2//!
3//! The crate is split into two independent halves:
4//!
5//! * [`rozpodil`] segments text into sentences and tokens, returning borrowed
6//!   [`Substring`](rozpodil::Substring) slices with byte offsets into the input.
7//! * [`uktextnorm`] rewrites numbers, dates, units, currencies, abbreviations and
8//!   other machine-readable spellings into the words a Ukrainian speaker would say.
9//!
10//! ```
11//! use ukrainian_tn::{rozpodil, uktextnorm};
12//!
13//! assert_eq!(uktextnorm::number_to_words(123), "сто двадцять три");
14//! let sentences = rozpodil::split_sentences("Перше речення. Друге.");
15//! assert_eq!(sentences.len(), 2);
16//! ```
17
18#![forbid(unsafe_code)]
19#![warn(missing_docs)]
20// These pedantic style lints conflict with deliberate crate design: the normalization
21// passes keep their regexes beside the transformation that uses them, several passes
22// are clearest as linear pipelines, and the public options type exposes independent
23// feature switches rather than an artificial state machine.
24#![allow(clippy::items_after_statements)]
25#![allow(clippy::struct_excessive_bools)]
26#![allow(clippy::too_many_lines)]
27
28pub mod rozpodil;
29pub mod uktextnorm;
30
31#[cfg(feature = "python")]
32mod python;
33
34/// The README, compiled as a doctest so its examples cannot drift from the API.
35#[cfg(doctest)]
36#[doc = include_str!("../README.md")]
37pub struct Readme;