This document describes how SeforimLibrary integrates with the SeforimAcronymizer database.
The SeforimLibrary generator pipeline downloads and uses the SeforimAcronymizer database to enrich books with alternative names (acronyms) for better searchability.
The SeforimAcronymizer database uses a normalized relational structure:
- Books: Stores unique book titles
- Acronyms: Stores unique acronym terms (deduplicated)
- BookAcronyms: Junction table linking books to their acronyms
This structure allows efficient storage (no duplication) and fast lookups.
The AcronymizerFetcher automatically downloads the latest acronymizer database from GitHub releases:
val dbPath = AcronymizerFetcher.ensureLocalDb(logger)
// Downloads to: build/acronymizer/acronymizer.dbDuring book insertion in DatabaseGenerator.insertBookOrCategory(), acronyms are fetched and inserted:
val terms = fetchAcronymsForTitle(bookTitle)
repository.bulkInsertBookAcronyms(bookId, terms)The fetchAcronymsForTitle() function queries the relational structure:
SELECT a.acronym
FROM Books b
JOIN BookAcronyms ba ON b.id = ba.book_id
JOIN Acronyms a ON ba.acronym_id = a.id
WHERE b.title = ?
ORDER BY a.acronymThis replaces the old CSV-based approach that used the AcronymResults view.
Acronyms are stored in SeforimLibrary's own book_acronym table:
CREATE TABLE book_acronym (
bookId INTEGER NOT NULL,
term TEXT NOT NULL,
PRIMARY KEY (bookId, term),
FOREIGN KEY (bookId) REFERENCES book(id) ON DELETE CASCADE
);./gradlew :otzariasqlite:generateLines \
-PseforimDb=/path/to/seforim.db \
-PsourceDir=/path/to/otzaria
# Acronymizer DB is auto-downloaded if not present./gradlew :otzariasqlite:generateLines \
-PseforimDb=/path/to/seforim.db \
-PsourceDir=/path/to/otzaria \
-PacronymDb=/path/to/custom/acronymizer.db./gradlew :otzariasqlite:downloadAcronymizer- Automatic Updates: Always uses the latest acronymizer database from releases
- Efficient Storage: Relational structure eliminates duplication
- Fast Lookups: Indexed columns enable quick book → acronyms queries
- Fallback-Safe: Pipeline continues if acronymizer DB is unavailable
After integration (typical dataset):
- ~6,878 books
- ~27,475 unique acronyms
- Average ~4 acronyms per book
- Acronymizer DB size: ~5.9 MB
The integration was updated to use the new relational structure (Books/Acronyms/BookAcronyms) instead of the deprecated CSV-based AcronymResults view. The old view is maintained for backward compatibility but is no longer used by SeforimLibrary.