Merge pull request 'bibclean: a name in capitals is allcaps_author, not author_list_commas' (#28) from bibclean-allcaps-author into main

This commit is contained in:
funkpower committed 2026-11-24 12:00:07 -05:00
commit 2dc90ea28d
3 files changed
+22 -1

No files matched your search

+2 -1
View File
@@ -198,6 +198,7 @@ bibclean books.ndjson | jq -c 'select(.slug_proposal.tier | IN("placeholder-auth
| `publisher_as_author` | 3 | An imprint in the author field | | `publisher_as_author` | 3 | An imprint in the author field |
| `title_in_author` | 3 | The title is a placeholder and the real title is in the author field | | `title_in_author` | 3 | The title is a placeholder and the real title is in the author field |
| `allcaps_title` | 2 | Shouting | | `allcaps_title` | 2 | Shouting |
| `allcaps_author` | 2 | The same, in the author field: "STEVEN BOX" |
| `lowercase_title` | 2 | A filename stub: "heidegger areopagite" | | `lowercase_title` | 2 | A filename stub: "heidegger areopagite" |
| `missing_apostrophe` | 2 | "Lossky s Argument" | | `missing_apostrophe` | 2 | "Lossky s Argument" |
| `possible_swap` | 2 | Title and author look to be the wrong way round | | `possible_swap` | 2 | Title and author look to be the wrong way round |
@@ -224,7 +225,7 @@ an author field is wrong while "Oxford, Michael" is a person.
| `junk_title` | "Microsoft Word - " and the like come off the front | | `junk_title` | "Microsoft Word - " and the like come off the front |
| `filename_title` | A document extension comes off the end | | `filename_title` | A document extension comes off the end |
| `placeholder_suffix` | The "- Unknown" comes off the end | | `placeholder_suffix` | The "- Unknown" comes off the end |
| `author_role_suffix`, `author_list_commas` | The heading put as a byline: dates, roles and fuller forms off, each name given names first, the names joined with "&". A field that is only "Surname, Given" is left alone, since some catalogues keep that order on purpose; `bibclean::heading::as_byline` turns it round for a caller that wants bylines | | `author_role_suffix`, `author_list_commas`, `allcaps_author` | The heading put as a byline: dates, roles and fuller forms off, each name given names first, the names joined with "&". A field that is only "Surname, Given" is left alone, since some catalogues keep that order on purpose; `bibclean::heading::as_byline` turns it round for a caller that wants bylines |
| `title_punctuation` | Set as a title page sets it; a full stop after an initial or abbreviation stays | | `title_punctuation` | Set as a title page sets it; a full stop after an initial or abbreviation stays |
| `numbered_title`, `release_tags` | The number comes off the front, the tags off the end. A series named in front as well ("Known Space-038-…") is `seriesof`'s, which keeps the series | | `numbered_title`, `release_tags` | The number comes off the front, the tags off the end. A series named in front as well ("Known Space-038-…") is `seriesof`'s, which keeps the series |
| `name_in_title` | The names come off the front, and the publisher, year and series off the end; the names are proposed as the author. Made only when the record has no real author, or already has the same one | | `name_in_title` | The names come off the front, and the publisher, year and series off the end; the names are proposed as the author. Made only when the record has no real author, or already has the same one |
+19
View File
@@ -169,6 +169,13 @@ pub fn as_byline(author: &str) -> Option<(String, Vec<&'static str>)> {
{ {
return None; return None;
} }
// Shouting, put in the case a title page prints names in: "STEVEN BOX".
if faults.is_empty()
&& original.chars().any(char::is_alphabetic)
&& !original.chars().any(char::is_lowercase)
{
faults.push("allcaps_author");
}
// Only the separator changed: "Patrick Laude, Barry McDonald". // Only the separator changed: "Patrick Laude, Barry McDonald".
if faults.is_empty() { if faults.is_empty() {
faults.push("author_list_commas"); faults.push("author_list_commas");
@@ -302,6 +309,18 @@ mod tests {
as_byline(author).map(|(name, _)| name) as_byline(author).map(|(name, _)| name)
} }
#[test]
fn a_name_in_capitals_is_named_as_shouting() {
assert_eq!(
as_byline("STEVEN BOX"),
Some(("Steven Box".to_string(), vec!["allcaps_author"]))
);
assert_eq!(
as_byline("Patrick Laude, Barry McDonald").map(|(_, faults)| faults),
Some(vec!["author_list_commas"])
);
}
#[test] #[test]
fn a_heading_is_turned_round() { fn a_heading_is_turned_round() {
for (heading, want) in [ for (heading, want) in [
+1
View File
@@ -153,6 +153,7 @@ const PERSON_SUFFIXES: &[&str] = &["ed", "eds", "ii", "iii", "iv", "jr", "md", "
/// What each fault is worth when the worst records are wanted first. /// What each fault is worth when the worst records are wanted first.
const WEIGHTS: &[(&str, u32)] = &[ const WEIGHTS: &[(&str, u32)] = &[
("account_author", 3), ("account_author", 3),
("allcaps_author", 2),
("allcaps_title", 2), ("allcaps_title", 2),
("author_is_title", 4), ("author_is_title", 4),
("author_last_first", 1), ("author_last_first", 1),