bindings: the author a record's own text can offer

book-pipeline had its own copy of bibclean's author recovery. Bound on all
four surfaces so it can stop.

Checked against that Python over all 5,385 books in the library: 5,375
identical. On the other ten the Python had taken a translator, an illustrator
or the publisher off a copyright line — Sally-Ann Spencer for *The Dwarves*,
Thomas Nelson for a table of contents, C. S. Lewis for a book about Tolkien —
and bibclean either finds the real author in the Library of Congress block or
says nothing. Every one of the ten was read by hand.
This commit is contained in:
funkpower
2026-09-20 15:10:35 -04:00
parent 2dfa370cd7
commit 7a08ed953d
11 changed files with 109 additions and 2 deletions
+22
View File
@@ -215,6 +215,17 @@ pub fn parse_identifier(text: &str) -> Option<idnorm::Identifier> {
idnorm::parse(text)
}
/// The best author a record's own title and front matter can offer.
///
/// `None` when neither says anything that reads as a person's name, which is
/// the honest answer for a scanned book with no title page.
pub fn suggest_author(
title: &str,
front_matter: Option<&str>,
) -> Option<bibclean::author::Suggestion> {
bibclean::author::best(title, front_matter)
}
/// Whether a chunk of body text carries footnote or endnote citations.
///
/// The structural signal a converter leaves on EPUB3 note definitions first;
@@ -269,6 +280,17 @@ mod tests {
assert_eq!(count_tokens("a passage"), textkit::count("a passage"));
}
#[test]
fn the_author_surface_agrees_with_the_library_underneath() {
const TITLE: &str = "Aquinas (Companion)";
const FRONT: &str = "THE CAMBRIDGE COMPANION TO AQUINAS\n\nedited by Norman Kretzmann";
assert_eq!(
suggest_author(TITLE, Some(FRONT)),
bibclean::author::best(TITLE, Some(FRONT))
);
assert!(suggest_author("", None).is_none());
}
#[test]
fn the_footnote_signal_agrees_with_the_library_underneath() {
const NOTES: &str = "1. John Smith, *A Title* (Oxford: Clarendon Press, 1998), 183.\n\