colophon: a byline line opening on an article names nobody

"A Novel", "A History", "A Psychoanalytic View" were read as people
with the initial A. Over the front matter of 5,551 books: 14 fewer
wrong names, no right one lost (precision 85.9% -> 86.7%). A rule
dropping any name made of the title's own words was tried and left
out: it also dropped real authors named in their titles ("Isaac Newton:
Philosophical Writings").
This commit is contained in:
funkpower committed 2026-11-24 09:01:57 -05:00
1 parent bd933157c9
commit 43f60e7cfc
1 file changed
+13
+13
View File
@@ -320,6 +320,12 @@ fn people(who: &str) -> Vec<String> {
.flat_map(|part| part.split(" and "))
.map(|name| name.trim().trim_end_matches(['.', ',']).trim().to_string())
.filter(|name| name.len() >= 3 && name.split_whitespace().count() <= 5)
// "A Novel", "A History": an article opens a line of the title, and
// would otherwise be read as the initial A.
.filter(|name| {
let first = name.split_whitespace().next().unwrap_or("");
!["a", "an", "the"].contains(&first.to_lowercase().as_str())
})
.filter_map(|name| bibclean::author::clean(&name))
.filter(|name| crate::cip::reads_as_a_name(name))
.filter(|name| name.split_whitespace().count() >= 2 || is_known_mononym(name))
@@ -669,6 +675,13 @@ mod person_tests {
}
}
#[test]
fn a_line_opening_on_an_article_names_nobody() {
assert!(people("A Novel").is_empty());
assert!(people("A Psychoanalytic View").is_empty());
assert_eq!(people("A. J. Ayer"), ["A. J. Ayer"]);
}
#[test]
fn initials_are_still_a_person() {
for line in ["A. J. Ayer", "A.J. Ayer", "Anne Carson"] {