Skip to main content

CI Python License: Elastic-2.0 Version Poetry

ia-kg — Internet Archive Book Downloader and Knowledge Graph Ingestion Pipeline

Author: Eric G. Suchanek, PhD Flux-Frontiers, Liberty TWP, OH


Overview

ia-kg downloads books from the Internet Archive as structured Markdown and ingests them into DocKG-backed knowledge graphs, ready for retrieval via KGRAG.

Books are organized by genre into a local corpus. Each volume is cleaned of OCR artifacts, segmented by chapter and section headings, and converted to well-structured Markdown — making it directly ingestible by dockg build. After ingestion, each book's knowledge graph is registered in the KGRAG registry and added to genre and global corpora for federated semantic retrieval.

ia-kg pairs naturally with doc-kg and KGRAG to form a complete pipeline from raw scanned text to queryable knowledge graph.


Features

  • Internet Archive integration — search, fetch metadata, and download DjVu text layers by identifier
  • OCR cleaning — normalizes Unicode ligatures, smart quotes, hyphenated line-breaks, running headers, page numbers, and table-of-contents blocks
  • Heading-aware Markdown conversion — detects CHAPTER / PART / SECTION / ALL-CAPS / Q&A headings and maps them to ## / ### / #### nodes
  • Catalog-driven batch download — tab-separated catalog files with identifier and optional title override; genre inferred from filename
  • Dynamic genre discovery — no hardcoded genre lists; scans corpus/ at runtime
  • DocKG ingestion — builds per-book .dockg/ indices and registers each in the KGRAG registry
  • Corpus and genre management — adds each book to a genre corpus (ia-<genre>) and a global ia-all corpus
  • Survey command — tabular status showing MD / reference / KG presence per book per genre
  • Dry-run support — all download and ingest commands accept --dry-run

Quick Start

# Search Internet Archive for texts
iakg download search "audels electric library"

# Download all books in a catalog
iakg download catalog scripts/catalogs/audel-electric.txt

# Show corpus status
iakg download survey

# Ingest into DocKG / KGRAG
iakg ingest --genre audel-electric

Installation

Requirements: Python ≥ 3.12, < 3.14

# pip (runtime only)
pip install ia-kg

# pip (with dev tools)
pip install 'ia-kg[dev]'

# pip (with PyCodeKG for codebase analysis)
pip install 'ia-kg[kgdeps]'

# Poetry
poetry add ia-kg

Note: kg-rag is not yet on PyPI. Install it from GitHub before using the ingest command:

pip install git+https://github.com/Flux-Frontiers/KGRAG.git

Usage

Download

# Search for texts on Internet Archive
iakg download search "audels electric library" -n 10

# Download a single item by identifier
iakg download book audels-electric-library-vol-1 --genre audel-electric

# Download from a catalog file (genre inferred from filename)
iakg download catalog scripts/catalogs/audel-electric.txt

# Force re-download even if already present
iakg download catalog scripts/catalogs/audel-electric.txt --force

# Dry run — print actions without writing files
iakg download catalog scripts/catalogs/audel-electric.txt --dry-run

# Survey corpus status (MD / reference / KG)
iakg download survey
iakg download survey --genre audel-electric

Ingest

iakg ingest --list-genres                         # list genres found in corpus/
iakg ingest                                       # ingest all genres
iakg ingest --genre audel-electric                # ingest one genre
iakg ingest --genre audel-electric --force-build  # rebuild even if .dockg exists
iakg ingest --push                                # git commit + push after each genre
iakg ingest --dry-run                             # print actions without executing

Catalog format

Catalog files are tab-separated, one item per line, with optional title override:

# Comments are ignored
audels-electric-library-vol-1	Audels Electric Library Vol. 1
audels-electric-library-vol-2

Place catalogs in scripts/catalogs/<genre>.txt — the genre is inferred from the filename stem.


Corpus Layout

corpus/
  <genre>/                        # e.g. audel-electric
    <Title>/                      # e.g. Audels Electric Library Vol. 1
      <slug>.md                   # structured Markdown (headings, Q&A, body)
      reference.md                # Internet Archive metadata sidecar
      .dockg/                     # DocKG knowledge graph index (after ingest)
        graph.sqlite
        lancedb/

Each book directory is a self-contained DocKG repository. Run dockg build inside any book directory to rebuild its index independently.


Adding a New Genre

  1. Create a catalog file at scripts/catalogs/<genre>.txt
  2. Add identifiers (verify with iakg download search)
  3. Download: iakg download catalog scripts/catalogs/<genre>.txt
  4. Ingest: iakg ingest --genre <genre>

No code changes are needed — genre discovery is fully dynamic.


License

Elastic License 2.0 — free for non-commercial and internal use; commercial redistribution requires a license from Flux-Frontiers.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ia_kg-0.1.1.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ia_kg-0.1.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file ia_kg-0.1.1.tar.gz.

File metadata

  • Download URL: ia_kg-0.1.1.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.13 Darwin/27.0.0

File hashes

Hashes for ia_kg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0b3ed76d74ca420a411c3b58d942a51ecd37654e952c767a90232b9c72b1711c
MD5 2e202bfa0d012937e6a6e2d001d147c2
BLAKE2b-256 1c7eb8de232f81cb8f2d44e78d9b6f72b9e64bd775c743ec883cf0ce48aa1fdb

See more details on using hashes here.

File details

Details for the file ia_kg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ia_kg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.13 Darwin/27.0.0

File hashes

Hashes for ia_kg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ad8d4ddeed6d0d3ad094d7067819c77d21e5228e22018419bc622810b260068
MD5 9a778382af07f3593f48d7ccbb78c448
BLAKE2b-256 46a316ab44d9916fefd995ecf9fb3249da2ea00c832b56adb3bdd36af953f2db

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page