mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-11-24 19:32:56 +00:00
bibclean: an ISBN-13's label is not part of the number
isbn::from_text read "ISBN-13 978-0-521-65706-8" as 1397805216: the label's 13 and the first eight digits. It now skips a -10/-13 label and returns the first announced number whose check digit agrees. isbn::fault names a stored ISBN that cannot be right, and problems() reports it: invalid_isbn, placeholder_isbn (000-0-000-00000-0) and isbn_with_label (ten digits beginning 13978 or 13979).
This commit is contained in:
3 files changed
+77
-10
No files matched your search
@@ -161,6 +161,8 @@ const WEIGHTS: &[(&str, u32)] = &[
|
||||
("edited_volume", 1),
|
||||
("filename_title", 3),
|
||||
("html_entity", 2),
|
||||
("invalid_isbn", 3),
|
||||
("isbn_with_label", 3),
|
||||
("junk_title", 3),
|
||||
("lowercase_title", 2),
|
||||
("missing_apostrophe", 2),
|
||||
@@ -171,6 +173,7 @@ const WEIGHTS: &[(&str, u32)] = &[
|
||||
("numeric_author", 4),
|
||||
("path_title", 4),
|
||||
("placeholder_author", 4),
|
||||
("placeholder_isbn", 3),
|
||||
("placeholder_suffix", 2),
|
||||
("placeholder_title", 4),
|
||||
("possible_swap", 2),
|
||||
@@ -303,12 +306,11 @@ pub fn problems(title: Option<&str>, author: Option<&str>, isbn: Option<&str>) -
|
||||
if title_in_author(Some(title), Some(author)) {
|
||||
reasons.push("title_in_author");
|
||||
}
|
||||
if isbn
|
||||
.unwrap_or("")
|
||||
.trim_matches(textkit::is_space)
|
||||
.is_empty()
|
||||
{
|
||||
let isbn = isbn.unwrap_or("").trim_matches(textkit::is_space);
|
||||
if isbn.is_empty() {
|
||||
reasons.push("missing_isbn");
|
||||
} else if let Some(fault) = crate::isbn::fault(isbn) {
|
||||
reasons.push(fault);
|
||||
}
|
||||
|
||||
reasons.into_iter().map(str::to_string).collect()
|
||||
|
||||
Reference in new issue
Block a user