diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-21 12:38:11 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-22 15:11:02 -0400 |
| commit | ba461c98594f41d53a29bdb6bd54640cd14cc810 (patch) | |
| tree | da538f13090f757d5771fdf0c78b35dcb263425f /src/sisudoc/outputs/io_out | |
| parent | check: languages of a document, against each other (diff) | |
check: warn when document's languages ocn diverge
The check runs once every language of a document has been abstracted.
Providing a warning by default. --strict makes divergence a failure,
taken at the end of the run so that outputs are complete and can be
examined. (the name --strict is general, so that later checks can be
added without a second flag).
Under --parallel the profiles are appended under synchronized, and the
comparison sorts a document's languages by name rather than taking
them in the order the threads finished, so two runs print the same
lines in the same order.
The outcome is noted per language in the database as
translation.ocn_aligned, for documents that have more than one
language.
(assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/outputs/io_out')
| -rw-r--r-- | src/sisudoc/outputs/io_out/sqlite_ocda_db.d | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/sisudoc/outputs/io_out/sqlite_ocda_db.d b/src/sisudoc/outputs/io_out/sqlite_ocda_db.d index 998c317..aa91e89 100644 --- a/src/sisudoc/outputs/io_out/sqlite_ocda_db.d +++ b/src/sisudoc/outputs/io_out/sqlite_ocda_db.d @@ -78,7 +78,7 @@ template spineAbstractionDb() { pod/<doc>/ the source tree pod/<doc>.zip the same, zipped pod/<doc>.digests.txt what is in them - pod/<uid>.ocda.db the abstraction, one per language + pod/<doc>.ocda.db the abstraction, every language of it +/ auto pths_pod = spinePathsPods!()(doc_matters); string base_pth = pths_pod.pod_dir_(); @@ -752,3 +752,53 @@ template spineAbstractionDb() { db.run("COMMIT TRANSACTION"); } } +/+ ↓ a metadata row for one language of a database, written after the fact. + . + For the one thing a language cannot know while it is being written: how + it compares with its siblings. The ocn alignment check can only run when + every language of a document has been abstracted, which is after this + database has been written, so the outcome is noted here in a pass of its + own rather than held for by the writer. + . + A row that is about the artefact and not in the .ssp, as source.ssp_digest + already is. It is INSERT OR REPLACE against UNIQUE(doc_id, key), so a + second run over the same file restates rather than accumulates. + . + Its own template: writing one row should not instantiate the writer. ++/ +template spineOcdaDbDocNote() { + @trusted void spineOcdaDbDocNote( + string db_file, + string lang, + string key, + string value, + ) { + import std.file : exists; + import d2sqlite3; + if (db_file.length == 0 || !db_file.exists) { return; } + try { + auto db = Database(db_file); + long _doc_id = -1; + { + auto _q = db.prepare("SELECT id FROM documents WHERE lang = :lang"); + _q.bind(":lang", lang); + foreach (row; _q.execute()) { _doc_id = row["id"].as!long; } + _q.finalize(); + } + if (_doc_id < 0) { return; } + auto _s = db.prepare( + "INSERT OR REPLACE INTO metadata (doc_id, key, value)" + ~ " VALUES (:doc_id, :key, :value)" + ); + _s.bind(":doc_id", _doc_id); + _s.bind(":key", key); + _s.bind(":value", value); + _s.execute(); + _s.finalize(); + } catch (Exception ex) { + import std.stdio : stderr; + stderr.writeln("WARNING: could not note ", key, " in ", db_file, + ": ", ex.msg); + } + } +} |
