mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-10-23 03:07:13 +00:00
bibfetch: ask every register that answers about a book, in turn
An ISBN is not a DOI. The body that assigns a DOI is the only one that has it, so one register is the whole answer. A book's identifier is assigned by its publisher and recorded by whoever gets round to it, and the record that comes back is as often as not missing the thing the caller wanted: asked about 9780199205592, OpenLibrary's edition record names *The First World War* and the press that printed it, and nobody at all as its author, because an edition record names its authors by key. So an ISBN now has a chain rather than a register. The edition record first, then OpenLibrary's own index — which answers with `author_name` filled in and costs nothing — and Google Books last, because it answers anonymous callers only until a daily quota runs out, after which it replies 429 to everyone behind the same address, as it is doing here today. The first complete answer wins, an incomplete one is kept in case nothing better comes, and a register being down is a failure only when every register is. `source` on the record says which one answered. colophon comes with it: the imprint reader was taking `Oxford is a registered trade mark of Oxford University Press` for a publisher and `Oxford N`, off `Oxford New York`, for a place. A legal notice mentioning a press is not the press, and a city is the city and not the first letter of the next one.
This commit is contained in:
@@ -26,7 +26,15 @@ static PUBLISHED_BY: LazyLock<Regex> = LazyLock::new(|| {
|
||||
.expect("a valid pattern")
|
||||
});
|
||||
static PRESS_LINE: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r"(?im)^\s*(?P<who>[A-Z][^\n]{2,58}?(?:University Press|Press|Publishers|Publishing|Books|Verlag))\s*[,.]?\s*$")
|
||||
Regex::new(r"(?im)^\s*(?P<who>[A-Z][^\n]{2,48}?(?:University Press|Press|Publishers|Publishing|Books|Verlag))\s*[,.]?\s*$")
|
||||
.expect("a valid pattern")
|
||||
});
|
||||
/// A sentence that merely mentions a press is not the press.
|
||||
///
|
||||
/// `Oxford is a registered trade mark of Oxford University Press` ends in a
|
||||
/// publisher's name and is a legal notice.
|
||||
static NOT_AN_IMPRINT: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r"(?i)( is | are | was |registered|trade mark|trademark|imprint of|division of|©|\(c\)|@|;|\d{4})")
|
||||
.expect("a valid pattern")
|
||||
});
|
||||
static FIRST_PUBLISHED: LazyLock<Regex> = LazyLock::new(|| {
|
||||
@@ -84,9 +92,10 @@ pub fn read(text: &str) -> Imprint {
|
||||
}
|
||||
|
||||
out.publisher = PUBLISHED_BY
|
||||
.captures(text)
|
||||
.or_else(|| PRESS_LINE.captures(text))
|
||||
.map(|caps| tidy(&caps["who"]));
|
||||
.captures_iter(text)
|
||||
.chain(PRESS_LINE.captures_iter(text))
|
||||
.map(|caps| tidy(&caps["who"]))
|
||||
.find(|who| !NOT_AN_IMPRINT.is_match(who) && who.split_whitespace().count() <= 8);
|
||||
out.year = FIRST_PUBLISHED
|
||||
.captures(text)
|
||||
.or_else(|| COPYRIGHT_YEAR.captures(text))
|
||||
@@ -97,8 +106,8 @@ pub fn read(text: &str) -> Imprint {
|
||||
.find(|line| crate::title::PLACE.is_match(line) && line.split_whitespace().count() <= 4)
|
||||
.and_then(|line| {
|
||||
crate::title::PLACE
|
||||
.find(line)
|
||||
.map(|m| tidy(m.as_str().trim_end_matches(|c: char| !c.is_alphabetic())))
|
||||
.captures(line)
|
||||
.map(|caps| tidy(&caps["city"]))
|
||||
});
|
||||
out
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ copyright|all rights reserved|printed in)\b",
|
||||
/// A city a publisher puts on a title page, alone on its line.
|
||||
pub static PLACE: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(
|
||||
r"(?i)^(oxford|cambridge|london|new york|new haven|chicago|boston|princeton|\
|
||||
r"(?i)^(?P<city>oxford|cambridge|london|new york|new haven|chicago|boston|princeton|\
|
||||
berlin|paris|munich|rome|madrid|grand rapids|edinburgh|dublin|toronto|sydney|\
|
||||
melbourne|minneapolis|philadelphia|san francisco|los angeles|leiden|amsterdam|\
|
||||
copenhagen|stockholm|moscow|beijing|tokyo|delhi|nairobi)\b[\s,·•|and]*",
|
||||
|
||||
Reference in New Issue
Block a user