diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-22 13:52:21 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-22 20:42:31 -0400 |
| commit | 51549f11d60cd353564486b3598e69259fb01b66 (patch) | |
| tree | 8dec193314d88ccfd76d80bc1cef951acf2b2204 /src/sisudoc/spine.d | |
| parent | .ssp document abstraction as PEG parsable text (diff) | |
document abstraction as per document sqlite db
--show-abstraction-db flag to write per-document
- SQLite database of document abstraction
(Claude-Code primary assist)
- Add a new output mode that serializes the in-memory document
abstraction to a per-document SQLite database. This complements
the .ssp text format (--show-abstraction) with a queryable
database representation of the same data.
- Schema:
metadata table - key/value pairs for document metadata
(title, creator, dates, rights, classify, identifiers,
language, notes, make settings, doc_has counts)
objects table - one row per document object with columns:
section, seq (position within section), ocn, is_a,
is_of_part, is_of_type, heading_level, identifier,
parent_ocn, last_descendant_ocn, ancestors,
indent/bullet/lang, has_* flags, segment/anchor tags,
table/code properties, text content
Indexed on: section, ocn, parent_ocn, is_a, heading_level
- Uses prepared statements via d2sqlite3 (existing dependency)
for safe and efficient insertion. Each document produces a
standalone .abstraction.db file in the abstraction/ output
directory.
- New files:
src/sisudoc/io_out/create_abstraction_db.d
Follows the same pattern as create_abstraction_txt.d.
Creates schema, populates metadata via key/value inserts,
then iterates all sections writing objects with prepared
statements within a single transaction.
- Changes to spine.d:
- Add "show-abstraction-db" to opts init, getopt, OptActions
- Add to abstraction(), require_processing_files(), and
meta_processing_general() gates
- Insert call at both spineAbstraction sites
- Tested against all 35 sample documents (including 9-language
live-manual) - zero failures. Works standalone or combined
with --show-abstraction and other output flags.
- Example queries the database supports:
SELECT ocn, heading_level, text FROM objects
WHERE is_a = 'heading' AND section = 'body';
SELECT * FROM objects WHERE parent_ocn = 10;
SELECT key, value FROM metadata WHERE key LIKE 'title.%';
Co-Authored-By: Anthropic Claude Opus 4.6 (1M context)
Diffstat (limited to 'src/sisudoc/spine.d')
| -rwxr-xr-x | src/sisudoc/spine.d | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d index ceb9d6c..f7b7d66 100755 --- a/src/sisudoc/spine.d +++ b/src/sisudoc/spine.d @@ -167,6 +167,7 @@ string program_name = "spine"; "pod" : false, "serial" : false, "show-abstraction" : false, + "show-abstraction-db" : false, "show-config" : false, "show-curate" : false, "show-curate-authors" : false, @@ -289,6 +290,7 @@ string program_name = "spine"; "serial", "serial processing", &opts["serial"], "skip-output", "skip output", &opts["skip-output"], "show-abstraction", "show document abstraction (write .ssp file)", &opts["show-abstraction"], + "show-abstraction-db", "show document abstraction (write .db sqlite file)", &opts["show-abstraction-db"], "show-config", "show config", &opts["show-config"], "show-curate", "show curate", &opts["show-curate"], "show-curate-authors", "show curate authors", &opts["show-curate-authors"], @@ -503,6 +505,9 @@ string program_name = "spine"; @trusted bool show_abstraction() { return opts["show-abstraction"]; } + @trusted bool show_abstraction_db() { + return opts["show-abstraction-db"]; + } @trusted bool show_curate() { return opts["show-curate"]; } @@ -752,6 +757,7 @@ string program_name = "spine"; return ( opts["abstraction"] || show_abstraction + || show_abstraction_db || concordance || source_or_pod || curate @@ -779,6 +785,7 @@ string program_name = "spine"; || odt || manifest || show_abstraction + || show_abstraction_db || show_make || show_metadata || show_summary @@ -794,6 +801,7 @@ string program_name = "spine"; return ( opts["abstraction"] || show_abstraction + || show_abstraction_db || curate || html || epub @@ -1316,6 +1324,11 @@ string program_name = "spine"; import sisudoc.io_out.create_abstraction_txt; spineAbstractionTxt!()(doc); } + /+ ↓ document abstraction sqlite database +/ + if (doc.matters.opt.action.show_abstraction_db) { + import sisudoc.io_out.create_abstraction_db; + spineAbstractionDb!()(doc); + } if (doc.matters.opt.action.curate) { auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( @@ -1420,6 +1433,11 @@ string program_name = "spine"; import sisudoc.io_out.create_abstraction_txt; spineAbstractionTxt!()(doc); } + /+ ↓ document abstraction sqlite database +/ + if (doc.matters.opt.action.show_abstraction_db) { + import sisudoc.io_out.create_abstraction_db; + spineAbstractionDb!()(doc); + } if (doc.matters.opt.action.curate) { auto _hvst = spineMetaDocCurate!()(doc.matters, hvst); if ( |
