More of what the pages around a title page carry: a dedication naming
somebody ("For Tom, Burney, and Bruce", "TO JILL PREWETT AND"), the
headings of the pages before the text ("ENDORSEMENTS", "About the
Authors", "Books by ...", "Author's Preface", "CHAPTER ONE"), printing
and edition lines, the author's moral-rights line, a Library of
Congress control number, an ebook's or a scanner's note ("digitized",
"with funding from"), a publisher's address ("P.O. Box", "a division
of"), award lines, and "visit us online". The longer printing of a
title read off the title page is no longer allowed to be one of them.
Over the front matter of 5,551 books, against the catalogue's titles:
titles that agree 2,669 -> 2,665, that disagree 560 -> 508. The four
no longer read were praise pages that happened to name the book.
"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").
The cataloguing block's statement of responsibility was split into
names and every short piece kept: "edited by" on its own, "translated
from the French", "Greg Palast. p. cm", "Irving B. Weiner;
editor-in-chief", "ISSN 0920-". Now the statement stops at the physical
description and the identifiers, roles before the names decide whose
they are ("selected and edited by", "[edited by]", "translated from"
skipped), a role after a name makes it an editor, an edition statement
after the names comes off, and each name has to pass bibclean's test of
a person's name, with two words or a known single name.
The title page's byline goes through the same test, so a series name or
a line of the title set in capitals beside the author ("MARESFIELD
LIBRARY", "A BASIC THEORY OF", "WISDOM'S Journey") is not taken for one.
Over the front matter of 5,551 books, against the catalogue's authors:
names read that agree 1,368 -> 1,320, that disagree 379 -> 217;
precision 78% -> 86%. The agreeing names no longer read were first
names standing alone ("Charlotte", "Alex").
html_entity (weight 2): "Master & Apprentice", left by a web page
the record was copied from. The named references a catalogue meets and
every numeric one are decoded first, before any rule reads the text; a
bare ampersand is left alone. Nine titles in a 6,022-record catalogue.
An author group is one person under several spellings, and in a
catalogue built from downloads the commonest spelling is often the
worst: "G.W.F. Hegel" on five books against "G. W. F. Hegel" on three,
"Saint Thomas (aquinas)", "S.J. Frederick Copleston", "Fyodor.
Dostoyevsky". Keeping it spreads it over every book in the group.
Author headings are now ranked by form first and by count only after:
a heading turned round (unless a suffix follows the comma), with a
bracket, a dangling separator, a suffix in front, or in capitals loses
to one without, however few books carry it; then stray full stops and
run-together initials. Respellings that are all well formed still go to
the commonest, so "Dostoëvsky" still merges into "Dostoevsky".
Publishers and subjects are ranked as before.
seriesof gains the numbered method: "Known Space-038-The Soft Weapon",
"Ice and Fire 2 - A Clash of Kings", "James Bond - 032 - Blast from the
Past" give the series, the number and the title without them. The
number has to stand between separators on both sides, so "The 200-Year
Plot", "The 12-Month Gardener" and "C.350-C.1450" stay titles. It is
looked for before a volume marker, so "Known Space-017-The Ethics of
Madness (Part 1)" is number 17 of Known Space and keeps its "Part 1".
bibclean names and repairs two more: numbered_title, a bare number in
front ("01 - The Three Musketeers", at most 200, so "911 - ..." and a
year stay), and release_tags after the title ("(BD) (v4 0) (lit)",
"(Scan, OCR)", "(no OCR)").
Over a 6,022-record catalogue: 73 numbered titles across Known Space,
Ice and Fire, James Bond, Wild Cards and Time Odyssey; 12 bare numbers;
4 sets of release tags. None wrong.
A page listing the other titles in a series prints each of their ISBNs
once, often before the copyright page, and was being taken for the
copyright page; the first ISBN read was then another book's. ISBNs are
now ranked over the whole front matter by how often they are printed
(the book's own appears in its cataloguing block and again on its
copyright line), the order printed breaking a tie, and the cataloguing
block's sorted list gives way to that ranking.
What is printed after an ISBN ("vol. 2", "hardback", "pbk.") is kept as
a note, and when the book's own title names a volume, the ISBN whose
note names the same volume comes first.
Over 398 books with printed ISBNs: three Cambridge Companions that read
another Companion's ISBN now read their own; eight more swap one
edition of the same book for another; nothing else changes.
url_title (weight 4): a title that is an http, file or www address. The
underscore repair no longer runs on an address or a path, where it
turned "stranger_than_fiction.htm" into "stranger than fiction.htm"
and left something that was neither a title nor an address.
heading::as_byline reads "Lossky, Vladimir, 1903-1958", "Vico,
Giambattista (Author)", "Kohut, Heinz.,Ornstein, Paul H." and "Patrick
Laude, Barry McDonald" as the names they are and prints them given
names first, joined with "&". Dates are years only; a role between two
names separates them; a fuller form is dropped only after an initial;
suffixes (Jr., S.J., père, Md/phd) stay where they are; the same person
twice is kept once. A result that is not plainly people (a firm, a
bracket left over, a word still in capitals, a name repeated as its own
given name) is refused.
clean() names and repairs author_role_suffix and the new
author_list_commas. A field that is only "Surname, Given" is left alone,
because some catalogues keep that order on purpose; as_byline still
turns it round for a caller that wants it.
Initials run together ("RR", "JC") and regnal numbers of any length
("XIII") are no longer cased as words.
Over a 6,022-record catalogue whose author field is a byline: 606
fields changed, read by hand; the wrong ones found on the way are now
tests.
name_in_title (weight 2): "Wilfred R Bion-Cogitations-Karnac Books
(1991)" puts the author in front of the title with a hyphen, as shadow
libraries name their downloads. The repair takes the names off the
front and the publisher, year and series off the end, and the names
are proposed as the author (method title_prefix, 0.75). Made only when
the record has no real author, or already names the same people, so a
series such as "Known Space-038-The Soft Weapon" by Larry Niven is left
alone. Compound words ("Socio-technical", "Non-Reductive") and runs of
capitals that are sentences ("Can Physicalism Be ...") are refused.
Over a 6,022-record catalogue: 28 records, each a real author in front
of a real title.
"BOOK ONE" at the top of a page means the page opens a part, and the
name under it is the part's. "A Bradford Book" and "A Scientific
American Book" are the imprint's line, set where a byline would be.
Over the front matter of 400 books: one more junk title becomes no
title, and nothing else changes.
author_is_title (weight 4): the author field is the whole title, or the
whole of the title before its subtitle when that part does not read as
a person. "Isaac Newton: Philosophical Writings" by Isaac Newton is not
caught; "Consciousness Reconsidered" by "Consciousness Reconsidered" is.
A record with this fault also gets an author proposed from its front
matter, as a missing or placeholder author already did.
Over a 6,022-record catalogue: 67 records, 37 distinct, none of them a
real author.
Every line added to the tests was read as a book's title off a real
library. Run over the front matter of 400 books, the only titles that
change are five of these, and each becomes no title at all.
textkit gains mojibake::repair, which reads UTF-8 that was decoded as
Windows-1252 back into what it was. It is certain rather than guessed:
every character has to turn back into a byte and the bytes have to be
valid UTF-8, which real Latin-1 text almost never is.
bibclean names two new faults, mojibake_title/mojibake_author and
placeholder_suffix, and now repairs four it only named before:
- mojibake in the title or author;
- "Microsoft Word - " and the like on the front of a title (junk_title);
- a document extension on the end (filename_title);
- a placeholder author on the end, "Title - Unknown" (placeholder_suffix).
A wrapper is taken off only when what is left is still a title, so
"Microsoft Word - Document2" and "0195152972.pdf" stay flagged.
"Document1", "Document2" and so on now count as placeholder titles.
Run over a 6,022-record catalogue: 120 records repaired by the new rules
(67 suffixes, 28 extensions, 21 prefixes, 4 mojibake), none of them wrong.
A lookup by ISBN took the year, publisher, language and page count from
Open Library's index, which answers for the work and gathers them from
every edition: Penguin's English War and Peace came back Spanish,
Norton's, and 1845. The index now gives only the title, the authors and
the subjects, and the edition record the rest (#6).
A cover must run to its end marker, FF D9 for a JPEG and IEND for a PNG,
so a body that only starts like an image is refused (#4). A relative
redirect whose query holds another address is resolved as relative (#5).
Closes#4, #5, #6.
Open Library's index answers about the work. Its publishers, languages,
first year and median page count are every edition's at once, and the
first of each is usually another edition's: ISBN 9780140447934, the
Penguin Classics War and Peace, came back Spanish, from W.W. Norton, in
1845.
The index is now asked only for what is true of the work (title,
subtitle, authors, subjects). A record from it is never complete, so
lookup always goes on to the edition record for container, language,
year and pages, then Google Books for whatever the edition record does
not say. A field neither gives is left out rather than filled from the
work.
Closes#6.
Open Library's title search, given an author as well, finds nothing for
The Ladder of Divine Ascent and four editions of Ladder of Divine Ascent.
When the title as given finds nothing, the title without a leading The, A
or An is asked, then the title and author as one free-text query, each
only when the one before found nothing. Google Books, whose anonymous
quota runs out, is asked only after all three.
A candidate whose edition gave an ISBN but no date or publisher took the
work's first_publish_year and first publisher, so one record could carry
one edition's ISBN and cover beside another's year and imprint. The id,
year, publisher, language and cover now come from the named edition only,
and are left out when it lacks them; the work gives only the title,
authors and subjects. A work with no edition named is named by its key,
not by an ISBN out of its editions' mixed list. The index is no longer
asked for the work-level fields, and gives no edition a length, so Open
Library candidates carry no pages.
When Open Library had nothing and Google Books failed, search answered
with no candidates and the CLI said no register had the title. The
failure is now the answer: Error::Limited for Google's 403, or 429 on
every attempt, which exits 75, and Error::Unreachable otherwise, exit 69.
The last route took any image whose id or address contained "cover", so
images/discover-ch1.png listed before images/cover.jpg won, and
recovery-map.png alone became the cover. A name now says cover only with
it as a word of its own: words break at anything not a letter or digit
and where a lower case letter meets a capital, so CoverImage and
Book_COVER still do. An image named cover outright comes first, then
manifest order. It is still a guess.
The guide's cover page took its first image, which can be a logo. Where
the page has several, the one whose file name, alt, id or class says
cover is taken; where none does, the first is, with a note saying how
many there were.
Each member was read no further than MAX_COVER, but nothing bounded how
many: two hundred cover-named images of 16 MiB took seven seconds to
inflate and left two hundred notes. One search now reads at most eight
members and stops with one note.
A percent-escape takes two hex digits and nothing else. from_str_radix
also takes a sign, so a%+fb decoded to a, 0x0f, b.
A zip whose members are all images was called cbz from their names alone,
so a folder of holiday photographs came back as a comic. It is now cbz
only when it carries a ComicInfo.xml or is itself named .cbz or .cbr;
otherwise it is unknown, with a note that it is a zip of N images and
would be a comic book if its name said .cbz. Only the archive's directory
is read, so members are still judged by name, and the README says so,
for a wrapped FictionBook too.
{\rtf has to be the whole control word: the byte after it must be the
version digit, a space or the next control word, so {\rtfoo is not RTF.
A FictionBook saved as UTF-16 was unknown. A byte-order mark in either
order now has the front decoded, at most 2048 code units, before the same
walk to the root element.
bookmeta: Cover::guessed says the file left the choice open — a Kindle
book's first image record, or an EPUB image picked because its name says
cover — so a caller with a register to ask can prefer that. A cover the
file names is never a guess. Cover::extension matches bibfetch's.
bibfetch: Open Library answers 403 to more than a hundred covers by ISBN
in five minutes from one address. That is now Error::Limited, not
Unreachable: the other form of the ISBN is not asked, the cover id still
is, since those are not limited, and the CLI exits 75. Covers asked by
ISBN are kept three seconds apart across the process (Covers::pace), which
stays under the limit however long a run goes. A deadline too long to add
to the clock no longer panics; it is no deadline.
bindings: fetch_cover and search_title for Python, and catena.Limited,
which fetch_identifier raises too when a register refuses for being asked
too often.
corpus-core: exit 75, a service refused for now.
A book that arrives as a file often has no identifier to ask about, only
a title and perhaps a name. `bibfetch search --title T [--author A]
[--limit N]` asks Open Library's index which books it has under those,
and Google Books only when Open Library has nothing, and prints one
record per candidate in the order the register gave them. From Rust,
`bibfetch::search(&agent, title, author, limit, attempts)`.
Each candidate is one edition. The index answers with works and, asked
for `editions.*`, names the edition of each that best matches; the ISBN,
publisher, language, year and cover come from that edition, the title,
authors, subjects and length from the work. The work's own ISBN list
mixes editions: the first War and Peace work lists four, while the
edition matched is a 1917 printing with none.
`id` is the first ISBN whose check digit agrees, in thirteen digits,
thirteen-digit entries taken first. A candidate with none is named by
the register's key: `olid` (OL…M for the edition, OL…W for the work when
no edition was named) or `googlebooks` (a volume id). Google's `OTHER`
shelfmarks are never read as ISBNs.
`cover_id` keeps the meaning it has in a lookup record: the edition's
own first cover, taken from `editions.cover_i` and only when the record
names that edition. The work's `cover_i` and `cover_edition_key` are not
asked for. A work with no edition named, and every Google Books
candidate, has none.
Open Library having nothing stands when Google Books is down; both down
is exit 69. Exit 0 a candidate, 1 none, 65 an empty title.
The retrying GET that lookups use is now `ask::get`, shared by both, and
no longer sleeps after its last attempt.
The cover is the first image reached by EPUB 3's cover-image property,
EPUB 2's <meta name="cover"> (by id, or by address where a converter wrote
one), the guide's cover page and the first <img> or SVG <image> on it, and
last any manifest image whose id or address says cover. A route that names
something unusable leaves a note and the next is asked.
Addresses are resolved against the document they are written in, with the
fragment off and percent-escapes undone; one that climbs out of the archive
or carries a scheme is not followed. Every member is read through a bound,
checked against the size the archive declares and enforced on the read
itself, so an understated entry stops at the cap too.
The media type is read off the bytes, now WebP as well, and a manifest that
disagrees is a note; bytes that are not an image are no cover. MAX_COVER
(16 MiB) is the cap for both formats, so a Kindle cover record larger than
that is left out as well.
Four formats a library of ebooks holds and this had no name for, so each
came back as text, as HTML or as unknown.
RTF is its opening group, after any byte-order mark and blank space.
Microsoft Reader is its signature at the front. A FictionBook is XML
whose root element is FictionBook, found by stepping over the
declaration, comments and doctype in the first four kilobytes. That walk
is over bytes rather than text, because a great many FictionBooks are
windows-1251 and would otherwise be called binary; other XML is still
HTML, as before.
A zip whose only real member is one FictionBook is zip-wrapped-fb2, the
same way a zipped PDF is zip-wrapped-pdf: handed to a converter as
FictionBook it is still a zip. A zip whose every real member is a JPEG,
PNG, GIF or WebP is cbz, once directories, ComicInfo.xml and desktop
clutter are passed over. One PDF or one readme among the pages and it is
not a comic. Only the names in the archive's directory are read, as for
every other zip.
The kind vocabulary grows by five: lit, fb2, rtf, cbz and
zip-wrapped-fb2.
When a MOBI or AZW3 file names no cover (no EXTH 201 or 202), the cover is
the record at the first image index if it is a JPEG, PNG or GIF, and
nothing otherwise, as calibre does (metadata/mobi.py:524-532). The walk to
the next image is gone: a later record may be an inline illustration, and
kindlegen puts a font or RESC record first.
EXTH 121 is no longer read, which also stops a stale KF8 boundary below
first_image from hiding the cover.
Review id 3 on catena#2.
P0: Record.cover_id came from the search index's cover_i, the cover
chosen for the whole work, and the index is asked first, so cover()
fell back to another edition's image (Penguin War and Peace,
9780140447934, got Standard Ebooks' Maude cover 12621906). cover_i is
no longer asked for or read; cover_id is the first positive id in the
edition record's covers, or None. An ISBN request that fails, as
opposed to a 404, now ends the fetch with that failure instead of
going on to the cover id.
Redirects go only over HTTPS on the standard port to
covers.openlibrary.org, archive.org or a host under archive.org, and
never to an address by number; the covers store the fetch began at is
still allowed.
The 1 KB size floor is gone. With default=false a missing cover is a
404, and the stand-in without it is a 43-byte GIF the media type check
refuses, so the floor could only drop real Small covers.
Covers.deadline (DEADLINE, two minutes) bounds a whole fetch: every
address, attempt, redirect, body and wait. It starts once the fetch
holds the process lock. The timeout test no longer times a span that
includes the lock wait.
EXTH 113 is an ASIN only when it is ten letters and digits; a UUID goes
under uuid, as the EPUB reader files it, and anything else under other.
With no EXTH 201 or 202, the first record from the first image index that
is a JPEG, PNG or GIF is the cover, stopping at the KF8 boundary (EXTH 121).
`bibfetch::cover(&agent, isbn, cover_id, size)` asks Open Library's covers
store by the ISBN's thirteen-digit form, then its ten-digit form, then by a
cover id a lookup record named, and returns the image or `Ok(None)`. The
answer is checked before it is trusted: JPEG or PNG by content type and by
magic bytes, between 1 KB and 10 MB, at most three redirects, none of them
off HTTPS. One request at a time per process; a 429 or 503 is waited out
for its Retry-After, up to a minute.
`idnorm::isbn` converts between the two forms, and only for an ISBN whose
check digit agrees. Lookup records carry `cover_id` from the edition record
and the search index. The CLI gains `bibfetch cover <isbn> -o <file>`.
A Kindle book's title, authors, publisher, description, ISBN, ASIN,
subjects, date and language come from the EXTH block, with the full name,
the Palm database name and the header's locale as fallbacks. The cover
image (EXTH 201, or the thumbnail) is returned as Metadata::cover with its
media type; it stays out of the JSON record. Every offset is bounds-checked:
a damaged header gives an empty record with a note, a broken EXTH block
keeps what came before the break, and an encrypted book is still read and
noted as drm.
Metadata gains description, which the EPUB reader now fills from
dc:description as well.
Fixtures are a story and cover written for the tests (CC0), converted with
calibre to MOBI 6 and AZW3, plus no-EXTH, DRM-flagged and truncated copies.
The commit that reordered the chain did not carry the version bump. The
bump was chained after check.sh with &&, the commit after a semicolon, so
a failing check skipped the bump and let the commit through. The tag then
pointed at a tree still calling itself 0.3.0, which the release workflow
asserts against and would have refused.
check.sh was failing because a test names which register is asked first
about an ISBN, which is exactly what changed. It now names the index, for
the reason the reorder happened.
The chain asked OpenLibrary's edition record first and its search index
second. The edition record is the slow one: measured against this
library it takes five to twenty-eight seconds, and it names its authors
by key, so a second request was needed anyway. The index, asked for its
fields by name, returns the title, the authors, the publisher, the
language, a page count and the subjects together, in about a quarter of
a second.
Reordering them turns three requests per book into one, and a pass over
five thousand books from fifty-three hours into well under one. The
edition record is still there for a subtitle or a publisher the index
did not give.
The chain asked three registers and returned whichever answered first
with a title and an author, discarding the rest. The registers are
complementary rather than redundant: OpenLibrary's edition record
carries the publisher, the pagination and the language and names its
authors by key, while its search index carries the authors and not the
publisher. One book, two half-answers, and the whole of it only if they
are put together.
They are merged now, first answer winning each field, so the order of
the chain is the order of trust. The record says which registers spoke.
It also carries what was being thrown away: subjects, language and a
page count, from whichever register has them. The index will not return
those unless asked for by name, which is how a language it held went
unread. Subjects are capped at twelve — the index lists every heading
every edition of a work has ever been given, which on a well-known book
is hundreds.
An edition record keeps its subtitle in a separate field, so a title
came back without it.
Read out of the review queue a real run produced, where each of these was
sitting as a proposed title waiting for a person to say no:
1. General Remarks a numbered heading
2 James W. McAllister a numbered heading
5222 What Is This a folio that ran into the line
827 North Fourth Street an address
Page xxxvi / Chapter I a marker
title a form label, printed literally
Sidebottom, Harry. Ancient a bibliography entry
To Mackenzie, a dedication
The numbers are the delicate part. A leading number that could be a year
is left alone, because 1984 Revisited is a book and 5222 What Is This is
a folio, and nothing else distinguishes them. A dedication has to end in
a comma, so To Kill a Mockingbird survives.
The copyright notices in the same pile are already fixed: those
proposals were written before 0.2.2 and are stale rather than wrong.
title_case counted small words from the start of the whole string, so
every subtitle that opened with one was set in lower case: 'Aesthetic in
Kant: a Critique', 'Born Fighting: the Scots-Irish'. A colon starts a
title of its own and the first word of one is capitalised however small
it is.
Found by book-pipeline, which had been proposing a title page's capitals
verbatim into a catalogue and needed this to stop.
'(c) Alfredo Ferrarin 2004' was read as a title. The notice pattern
wanted the year to follow the symbol directly, and a copyright line puts
the holder's name in between, which is the ordinary way to set one.
read_colophon is several milliseconds of computation over a few hundred
kilobytes, and it held the GIL for all of them. A caller reading a
library through asyncio.to_thread therefore got no overlap whatsoever:
six books in flight, one book's worth of work at a time.
Measured on this library, that was most of why a concurrent pass still
paced at four and a half hours.
colophon has composed the question about what its pages did not settle
since it was written, and merged a reply back into the record it read.
Both were reachable only from a terminal, so a pipeline wanting the same
fallback would have had to write its own prompt — a second one, drifting
from the first, asking for a shape merge does not accept.
merge fills only the unsettled fields, so a model cannot overwrite what a
book printed about itself. That is the property that makes asking one
safe, and it belongs to colophon rather than to any caller.
Read against five thousand real books, the title page is often not the
first thing in the file, and what is there instead has shape. Six kinds
of it were being read as titles:
vi CONTENTS a folioed heading
Copyright (c) 2013 by Barry Davies, BEM a notice
Translated from the French by Willard R. Trask a credit
Vol. 11. HENRY JAMES, JR. a collected edition's list
[PART ONE: a part heading
Piper Verlag GmbH, Munich<span style=... a converter's leavings
Rejecting one line only moves the misread down one, because a page that
converted badly converted badly throughout, so the whole shape goes:
markdown links, stylesheet declarations, HTML entities, epub filenames,
and the sentences a copyright page sets.
The notice pattern wants the symbol or the year, never the word alone.
The first draft rejected 'Copyright and Its Discontents', which its own
test caught.
On sixty books this drops five claimed titles, all of them wrong, and
fixes six that were reading one homily's heading for every other
homily's title.