diff --git a/arkindex/documents/export/structure.sql b/arkindex/documents/export/structure.sql index d233ab243daff17419d4f1bd4c79c32307694a13..b82d67c24a970c15094206b2c13624f90031a6e5 100644 --- a/arkindex/documents/export/structure.sql +++ b/arkindex/documents/export/structure.sql @@ -73,11 +73,13 @@ CREATE TABLE transcription ( element_id VARCHAR(37) NOT NULL, text TEXT NOT NULL, confidence REAL, + orientation TEXT NOT NULL DEFAULT 'horizontal-lr', worker_version_id VARCHAR(37), PRIMARY KEY (id), FOREIGN KEY (element_id) REFERENCES element (id) ON DELETE CASCADE, FOREIGN KEY (worker_version_id) REFERENCES worker_version (id) ON DELETE CASCADE, - CHECK (confidence IS NULL OR (confidence >= 0 AND confidence <= 1)) + CHECK (confidence IS NULL OR (confidence >= 0 AND confidence <= 1)), + CHECK (orientation IN ('horizontal-lr', 'horizontal-rl', 'vertical-lr', 'vertical-rl')) ); CREATE TABLE classification ( diff --git a/arkindex/documents/export/transcription.sql b/arkindex/documents/export/transcription.sql index 1dc0f0402ae717e5f4959f11b2b1566cda851b62..251497e89dd341a1e769b6b0052d6bfc78af98fb 100644 --- a/arkindex/documents/export/transcription.sql +++ b/arkindex/documents/export/transcription.sql @@ -3,6 +3,7 @@ SELECT transcription.element_id, transcription.text, transcription.confidence, + transcription.orientation, transcription.worker_version_id FROM documents_transcription transcription INNER JOIN documents_element element ON (element.id = transcription.element_id) diff --git a/arkindex/documents/management/commands/load_export.py b/arkindex/documents/management/commands/load_export.py index f3ff303c9aa7db50bdaf7c6bb3cf4b2fdeb35a68..9b325aaeb605c42bc619ffbf27e662194966fa83 100644 --- a/arkindex/documents/management/commands/load_export.py +++ b/arkindex/documents/management/commands/load_export.py @@ -250,6 +250,7 @@ class Command(BaseCommand): element_id=row["element_id"], text=row["text"], confidence=row["confidence"], + orientation=row["orientation"], worker_version_id=self.worker_version_map[row["worker_version_id"]] if row["worker_version_id"] else None, )] diff --git a/arkindex/documents/tests/tasks/test_export.py b/arkindex/documents/tests/tasks/test_export.py index 5396b92b5b84ebb65c63ce730be465a9f1f19c05..3b35f95e5621c4c313147cb27401994054522ce4 100644 --- a/arkindex/documents/tests/tasks/test_export.py +++ b/arkindex/documents/tests/tasks/test_export.py @@ -286,13 +286,14 @@ class TestExport(FixtureTestCase): ) self.assertCountEqual( - db.execute("SELECT id, element_id, text, confidence, worker_version_id FROM transcription").fetchall(), + db.execute("SELECT id, element_id, text, confidence, orientation, worker_version_id FROM transcription").fetchall(), [ ( str(transcription.id), str(transcription.element_id), transcription.text, transcription.confidence, + transcription.orientation.value, str(transcription.worker_version_id) if transcription.worker_version_id else None ) for transcription in Transcription.objects.filter(element__corpus=self.corpus)