Skip to main content

csan_core/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Cutter call number generation for library cataloging.
4//!
5//! `csan-core` derives shelf-ready cutter numbers from author names (or, for
6//! anonymous works, titles) using two methods:
7//!
8//! * **Cutter-Sanborn three-figure** — a lookup against the bundled
9//!   Cutter-Sanborn table, with optional call number prefix and lowercase
10//!   work mark ([`CutterSanbornMethod`]).
11//! * **Library of Congress** — the `LoC` character-branching rules,
12//!   producing an initial plus a digit sequence ([`CutterLocMethod`]).
13//!
14//! Input names are normalized first: whitespace and punctuation are
15//! stripped, diacritics are folded to ASCII, `Mc`/`M'` prefixes expand to
16//! `Mac`, and a surname of `St`/`Ste` expands to `Saint`/`Sainte`,
17//! matching the conventions of the underlying tables. On request, a title is
18//! filed without its initial article in a given [`Language`] (see
19//! [`Opus::with_article_language`] and [`catalog::language`]).
20//!
21//! # Example
22//! ```
23//! use csan_core::{
24//!     Attribution, Author, CutterConfig, CutterGenerator, CutterLocMethod,
25//!     CutterSanbornMethod, Opus,
26//! };
27//!
28//! let entry = Attribution::Both {
29//!     author: Author::new("Charles", "Dickens"),
30//!     opus: Opus::new("Oliver Twist"),
31//! };
32//!
33//! let sanborn = CutterSanbornMethod::generate(&entry, CutterConfig::default())?;
34//! assert_eq!(sanborn.to_string(), "D548o");
35//!
36//! let loc = CutterLocMethod::generate(&entry, CutterConfig::default())?;
37//! assert_eq!(loc.to_string(), "D535");
38//! # Ok::<(), csan_core::NormalizationError>(())
39//! ```
40pub mod catalog;
41
42pub use catalog::{
43    cutter::{
44        CutterConfig, CutterGenerator, CutterLocMethod, CutterSanbornMethod, Detailed,
45        DetailedError, detailed_json,
46    },
47    language::{Language, MissingLanguage, UnknownLanguage},
48    models::{Attribution, Author, CutterLoc, CutterSanborn, CutterType, Opus},
49    normalization::NormalizationError,
50};