Fill the hierarchy's place words from other records with the same code
When a book's own Library of Congress record has no subject heading, the place or topic words now come from a verified record of the same work with the same class key, and failing that from the part that the similar-search records with that key agree on. Books that previously found nothing are re-checked once at startup. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
60fa4ef6f7
commit
c1996d2b47
6 files changed
+279
-25
No files matched your search
+10
-4
@@ -4,6 +4,12 @@ import type { Resolver } from './resolve/resolver.ts';
|
||||
|
||||
export const DEFAULT_RETRY_DELAYS_MS = [5_000, 30_000, 120_000];
|
||||
|
||||
/**
|
||||
* Version of the rules that decide a book's hierarchy tail. Raising it sends every book with an empty tail (not
|
||||
* hand-entered) through the backfill once more at the next start. 2: other records with the book's class key count.
|
||||
*/
|
||||
export const TAIL_RULES_VERSION = 2;
|
||||
|
||||
export type ResolverLike = Resolver;
|
||||
|
||||
export interface Jobs {
|
||||
@@ -147,8 +153,6 @@ export function createJobs(deps: {
|
||||
}
|
||||
}
|
||||
|
||||
/** Sources whose number never comes with a tail of its own: borrowed from similar books, or entered by hand. */
|
||||
const NO_TAIL_SOURCES = new Set(['similar', 'manual']);
|
||||
|
||||
async function backfillTail(id: number): Promise<void> {
|
||||
const book = db.getBook(id);
|
||||
@@ -156,7 +160,7 @@ export function createJobs(deps: {
|
||||
const label = book.isbn13 ?? book.lccn ?? book.title;
|
||||
// Only the tail column is ever written here: the number, sort key, confidence, source, status, queue flag and
|
||||
// printed date stay as they are.
|
||||
if ((!book.isbn13 && !book.lccn) || book.manualOverride || (book.source && NO_TAIL_SOURCES.has(book.source))) {
|
||||
if (book.manualOverride || book.source === 'manual') {
|
||||
tailAttempts.delete(id);
|
||||
emit(id, { hierarchyTail: [] });
|
||||
return;
|
||||
@@ -166,7 +170,7 @@ export function createJobs(deps: {
|
||||
const tail = await resolver.tail({
|
||||
...(book.isbn13 ? { isbn13: book.isbn13 } : {}), ...(book.lccn ? { lccn: book.lccn } : {}),
|
||||
title: book.title, ...(book.authors[0] ? { author: book.authors[0] } : {}),
|
||||
viaTitle: book.source === 'loc-title' || book.source === 'ol-work',
|
||||
...(book.subtitle ? { subtitle: book.subtitle } : {}), subjects: book.subjects, callNumber: book.callNumber,
|
||||
});
|
||||
tailAttempts.delete(id);
|
||||
emit(id, { hierarchyTail: tail });
|
||||
@@ -218,6 +222,8 @@ export function createJobs(deps: {
|
||||
},
|
||||
resume() { for (const id of db.listPendingIds()) this.enqueue(id); },
|
||||
resumeTails() {
|
||||
const n = db.recheckEmptyTails(TAIL_RULES_VERSION);
|
||||
if (n > 0) log(`[tail] ${n} book(s) with an empty tail will be checked again under the newer rules`);
|
||||
for (const id of db.listTailMissingIds()) if (!tailQueue.includes(id)) tailQueue.push(id);
|
||||
start();
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user