Datasets:
Tasks:
Text Classification
Formats:
parquet
Languages:
Ancient Greek (to 1453)
Size:
100K - 1M
License:
Represent text chunks as JSON lists
Browse files- README.md +10 -2
- data/prose_1/test-00000-of-00001.parquet +2 -2
- data/prose_1/train-00000-of-00001.parquet +2 -2
- data/prose_1/validation-00000-of-00001.parquet +2 -2
- data/prose_10/test-00000-of-00001.parquet +2 -2
- data/prose_10/train-00000-of-00001.parquet +2 -2
- data/prose_10/validation-00000-of-00001.parquet +2 -2
- data/prose_100/test-00000-of-00001.parquet +2 -2
- data/prose_100/train-00000-of-00001.parquet +2 -2
- data/prose_100/validation-00000-of-00001.parquet +2 -2
- data/verse_metre_1/test-00000-of-00001.parquet +2 -2
- data/verse_metre_1/train-00000-of-00001.parquet +2 -2
- data/verse_metre_1/validation-00000-of-00001.parquet +2 -2
- data/verse_metre_10/test-00000-of-00001.parquet +2 -2
- data/verse_metre_10/train-00000-of-00001.parquet +2 -2
- data/verse_metre_10/validation-00000-of-00001.parquet +2 -2
- data/verse_metre_100/test-00000-of-00001.parquet +2 -2
- data/verse_metre_100/train-00000-of-00001.parquet +2 -2
- data/verse_metre_100/validation-00000-of-00001.parquet +2 -2
- data/verse_sentence_1/test-00000-of-00001.parquet +2 -2
- data/verse_sentence_1/train-00000-of-00001.parquet +2 -2
- data/verse_sentence_1/validation-00000-of-00001.parquet +2 -2
- data/verse_sentence_10/test-00000-of-00001.parquet +2 -2
- data/verse_sentence_10/train-00000-of-00001.parquet +2 -2
- data/verse_sentence_10/validation-00000-of-00001.parquet +2 -2
- data/verse_sentence_100/test-00000-of-00001.parquet +2 -2
- data/verse_sentence_100/train-00000-of-00001.parquet +2 -2
- data/verse_sentence_100/validation-00000-of-00001.parquet +2 -2
- inspection/README.md +9 -2
- inspection/sphragis.sqlite +2 -2
- metadata/build_report.json +116 -115
- scripts/build_dataset.py +12 -3
- scripts/dataset_variants.py +13 -4
- scripts/text_units.py +32 -0
- scripts/validate_dataset.py +28 -6
- tests/test_split_stratification.py +23 -6
- tests/test_verse_character_coverage.py +4 -1
README.md
CHANGED
|
@@ -188,6 +188,12 @@ All configurations contain:
|
|
| 188 |
revision, URL, license, annotation provenance and syntax scheme;
|
| 189 |
- `licenses`, `dedup_key`, and `split`.
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
The `_10` and `_100` configurations additionally contain `chunk_size`,
|
| 192 |
`chunk_target_size`, ordered `constituent_ids`, JSON
|
| 193 |
`constituent_provenance`, `chunk_work_ids`, `chunk_works`, and
|
|
@@ -197,8 +203,10 @@ rows always have `chunk_size` equal to the configuration suffix. Aggregated
|
|
| 197 |
retains the original passage-level locations.
|
| 198 |
|
| 199 |
`verse_sentence` additionally contains `metrical_line_ids` and a JSON list of
|
| 200 |
-
the
|
| 201 |
-
`
|
|
|
|
|
|
|
| 202 |
`book`, `poem_sequence`, `line_number`, raw Hypotactic `metre`, flattened
|
| 203 |
syllable-level annotations, and the originating filename. Its `conllu` value is
|
| 204 |
a valid multi-sentence CoNLL-U document when a line crosses a sentence
|
|
|
|
| 188 |
revision, URL, license, annotation provenance and syntax scheme;
|
| 189 |
- `licenses`, `dedup_key`, and `split`.
|
| 190 |
|
| 191 |
+
`text` is always a JSON list of strings. Atomic `_1` rows and training rows
|
| 192 |
+
contain one string; validation and test rows in `_10` and `_100` contain
|
| 193 |
+
exactly 10 or 100 separate sentence strings (`verse_sentence` and `prose`) or
|
| 194 |
+
line strings (`verse_metre`). No whitespace separator is used to encode unit
|
| 195 |
+
boundaries.
|
| 196 |
+
|
| 197 |
The `_10` and `_100` configurations additionally contain `chunk_size`,
|
| 198 |
`chunk_target_size`, ordered `constituent_ids`, JSON
|
| 199 |
`constituent_provenance`, `chunk_work_ids`, `chunk_works`, and
|
|
|
|
| 203 |
retains the original passage-level locations.
|
| 204 |
|
| 205 |
`verse_sentence` additionally contains `metrical_line_ids` and a JSON list of
|
| 206 |
+
the overlapping `metrical_lines`. Each serialized line is strictly limited to
|
| 207 |
+
`text`, `metre`, and `syllables`; identifying Hypotactic metadata and internal
|
| 208 |
+
IDs are never included in this model-facing field. `verse_metre` contains the
|
| 209 |
+
native list `parent_sentence_ids`,
|
| 210 |
`book`, `poem_sequence`, `line_number`, raw Hypotactic `metre`, flattened
|
| 211 |
syllable-level annotations, and the originating filename. Its `conllu` value is
|
| 212 |
a valid multi-sentence CoNLL-U document when a line crosses a sentence
|
data/prose_1/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e1427fca5d4efd1a843db94fe2c0f9476d3fcfada5c23f8b6c67f26e460ff64f
|
| 3 |
+
size 1225487
|
data/prose_1/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5eeaaba94135ecaa8190832d95d0154d908c36a8e2aee440970c1ea06eb1dcb8
|
| 3 |
+
size 11047428
|
data/prose_1/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b13263866f6ae938bd029e01ad90d4ffde49a3ec59b07907765ea80f9e1eb44a
|
| 3 |
+
size 1228039
|
data/prose_10/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa6a26cfeeb182cfae24790508d959af62bf031750df08524d6f617a7cdbdd97
|
| 3 |
+
size 1070435
|
data/prose_10/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9219a49732f1ca2cfe1e1a05fb355e68cae2bb3ded12e125c84588c2dc54e32
|
| 3 |
+
size 11954298
|
data/prose_10/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:437257da9e82ea9f1146edae9057c6ebb7ea8f0519b8a316bec8e42384193c31
|
| 3 |
+
size 1065929
|
data/prose_100/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c6ad6df02726e31a1be2be4bdb605d05a5bbee6b043d66211ff7eaef729115d7
|
| 3 |
+
size 1017901
|
data/prose_100/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c49570a2134db2995f410af8adf95f66fa50804f48b31dce7f13aef7dcf1888f
|
| 3 |
+
size 11954298
|
data/prose_100/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46fbe75f312ca73a61056ed0a31acca8a3baa8cfac39740e4bd822f82bf83b9c
|
| 3 |
+
size 1019329
|
data/verse_metre_1/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a1d00311cf5c03f8792854fe8c05d6a821833c281d8818a637dcfc1bd16b1bdf
|
| 3 |
+
size 1131885
|
data/verse_metre_1/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2fae60f1ee2c79f3bb269e1e49eabf9c687591ec0deb89936194d1b17e05f455
|
| 3 |
+
size 6048972
|
data/verse_metre_1/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15194b38cdce47ed7835fffaab53793651ac70ed0655e2ba63b57746ed81d7e3
|
| 3 |
+
size 1142469
|
data/verse_metre_10/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9857f0fc118df03093ccb481041bab1974eb7f5651abde10a2343d16a79f3fdd
|
| 3 |
+
size 982348
|
data/verse_metre_10/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7d3f546988a9d8125fc51b5944fd0cbdaf37e5a5c503f655734d19a597550aa
|
| 3 |
+
size 6780475
|
data/verse_metre_10/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f88672665bab7fcfa8bd41a8be85c1124cd58dc4ec07f7a6ac8f7e927091b2f
|
| 3 |
+
size 987833
|
data/verse_metre_100/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e9258f3211faee3a51ed68e2e0681fc13ff56de608545ebf9be6cafbe144812
|
| 3 |
+
size 944981
|
data/verse_metre_100/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff14d9c5c24e63abf9cf3e8c7ce259e296d63762be62b7915bc309c29cda9a29
|
| 3 |
+
size 6780475
|
data/verse_metre_100/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:236bca4e8c7a0fde7e2aaa1b63257b2e39e258e3c5ea7eec77d4260223ee357a
|
| 3 |
+
size 950741
|
data/verse_sentence_1/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c37d439c0003c05757d3779595f9b57849d42879ba01d8b0089248a5f676eff4
|
| 3 |
+
size 752329
|
data/verse_sentence_1/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:926a5fee9d1fda5795b0db9f7b8169c22da89b6a0d5b33a687f76c1fdf5294cc
|
| 3 |
+
size 5646102
|
data/verse_sentence_1/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a283d6f59cc42b085ae8ce6a5e6e02c85bc5a543ac58606b8828282a7ebaf1d0
|
| 3 |
+
size 746879
|
data/verse_sentence_10/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8dbb0751a353a9fe62f5c07fae3b019de644252ecd9204b0bde77ad7879e2218
|
| 3 |
+
size 662250
|
data/verse_sentence_10/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e01495b59bd2a23623dcd18bfef762dda08b068c5a5248c9394f9dce4a348867
|
| 3 |
+
size 6031221
|
data/verse_sentence_10/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f3b24962f00be97e3b9f13871a465dab201521b08bfffc3e85108e23a7dffab
|
| 3 |
+
size 658460
|
data/verse_sentence_100/test-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:615703b0fcac44a20d138165448be6bfa446def447956d1a712182df48460fb0
|
| 3 |
+
size 635279
|
data/verse_sentence_100/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2efb7b94f86308c96aa5719f9c76b26969c2c1521b8a547aaa3df575d8a13e9
|
| 3 |
+
size 6031221
|
data/verse_sentence_100/validation-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ae48b0a6d93a860785280aed8420500a4f829100207e5320f96000291a265d8
|
| 3 |
+
size 629496
|
inspection/README.md
CHANGED
|
@@ -9,11 +9,18 @@ Each configuration is a table named after the configuration, for example
|
|
| 9 |
text. `_split_row_index` records the original physical row order within each
|
| 10 |
split. `_mirror_manifest` records row counts, column lists, and content hashes.
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
```sh
|
| 15 |
sqlite3 -readonly -line inspection/sphragis.sqlite \
|
| 16 |
-
"SELECT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
```
|
| 18 |
|
| 19 |
List the available tables with:
|
|
|
|
| 9 |
text. `_split_row_index` records the original physical row order within each
|
| 10 |
split. `_mirror_manifest` records row counts, column lists, and content hashes.
|
| 11 |
|
| 12 |
+
The top-level `text` column is a JSON list: one string for atomic rows and one
|
| 13 |
+
string per constituent sentence or line for evaluation chunks. For example,
|
| 14 |
+
retrieve the ten separate sentences in the first validation row as follows:
|
| 15 |
|
| 16 |
```sh
|
| 17 |
sqlite3 -readonly -line inspection/sphragis.sqlite \
|
| 18 |
+
"SELECT key AS sentence_index, value AS sentence
|
| 19 |
+
FROM json_each((
|
| 20 |
+
SELECT text FROM verse_sentence_10
|
| 21 |
+
WHERE split = 'validation'
|
| 22 |
+
ORDER BY _split_row_index LIMIT 1
|
| 23 |
+
));"
|
| 24 |
```
|
| 25 |
|
| 26 |
List the available tables with:
|
inspection/sphragis.sqlite
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f4d0e67fae064366d2e854f42e2cb69ac39be2600e2f3d97f19f2f0b29e72f6
|
| 3 |
+
size 1257635840
|
metadata/build_report.json
CHANGED
|
@@ -539,49 +539,49 @@
|
|
| 539 |
},
|
| 540 |
"data_files": {
|
| 541 |
"prose_1": {
|
|
|
|
| 542 |
"train": 25730,
|
| 543 |
-
"validation": 2800
|
| 544 |
-
"test": 2800
|
| 545 |
},
|
| 546 |
"prose_10": {
|
|
|
|
| 547 |
"train": 25730,
|
| 548 |
-
"validation": 280
|
| 549 |
-
"test": 280
|
| 550 |
},
|
| 551 |
"prose_100": {
|
|
|
|
| 552 |
"train": 25730,
|
| 553 |
-
"validation": 28
|
| 554 |
-
"test": 28
|
| 555 |
-
},
|
| 556 |
-
"verse_sentence_1": {
|
| 557 |
-
"train": 11914,
|
| 558 |
-
"validation": 1400,
|
| 559 |
-
"test": 1400
|
| 560 |
-
},
|
| 561 |
-
"verse_sentence_10": {
|
| 562 |
-
"train": 11914,
|
| 563 |
-
"validation": 140,
|
| 564 |
-
"test": 140
|
| 565 |
-
},
|
| 566 |
-
"verse_sentence_100": {
|
| 567 |
-
"train": 11914,
|
| 568 |
-
"validation": 14,
|
| 569 |
-
"test": 14
|
| 570 |
},
|
| 571 |
"verse_metre_1": {
|
|
|
|
| 572 |
"train": 21818,
|
| 573 |
-
"validation": 2600
|
| 574 |
-
"test": 2600
|
| 575 |
},
|
| 576 |
"verse_metre_10": {
|
|
|
|
| 577 |
"train": 21818,
|
| 578 |
-
"validation": 260
|
| 579 |
-
"test": 260
|
| 580 |
},
|
| 581 |
"verse_metre_100": {
|
|
|
|
| 582 |
"train": 21818,
|
| 583 |
-
"validation": 26
|
| 584 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
}
|
| 586 |
},
|
| 587 |
"deduplication": {
|
|
@@ -938,150 +938,151 @@
|
|
| 938 |
}
|
| 939 |
},
|
| 940 |
"validation": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
"prose_1": {
|
| 942 |
-
"rows": 31330,
|
| 943 |
"authors": 12,
|
| 944 |
-
"
|
| 945 |
"sources": {
|
|
|
|
| 946 |
"gorman": 17977,
|
| 947 |
-
"ud_perseus": 4306,
|
| 948 |
"pedalion": 2447,
|
| 949 |
-
"
|
| 950 |
-
"
|
| 951 |
},
|
| 952 |
"splits": {
|
|
|
|
| 953 |
"train": 25730,
|
| 954 |
-
"validation": 2800
|
| 955 |
-
|
| 956 |
-
|
| 957 |
},
|
| 958 |
"prose_10": {
|
| 959 |
-
"rows": 26290,
|
| 960 |
"authors": 12,
|
| 961 |
-
"
|
| 962 |
"sources": {
|
|
|
|
| 963 |
"gorman": 15088,
|
| 964 |
-
"
|
| 965 |
"pedalion": 2059,
|
| 966 |
-
"
|
| 967 |
-
"
|
| 968 |
-
"multiple": 26
|
| 969 |
},
|
| 970 |
"splits": {
|
|
|
|
| 971 |
"train": 25730,
|
| 972 |
-
"validation": 280
|
| 973 |
-
|
| 974 |
-
|
| 975 |
},
|
| 976 |
"prose_100": {
|
| 977 |
-
"rows": 25786,
|
| 978 |
"authors": 12,
|
| 979 |
-
"
|
| 980 |
"sources": {
|
|
|
|
| 981 |
"gorman": 14806,
|
| 982 |
-
"
|
| 983 |
"pedalion": 2022,
|
| 984 |
-
"
|
| 985 |
-
"
|
| 986 |
-
"multiple": 16
|
| 987 |
},
|
| 988 |
"splits": {
|
|
|
|
| 989 |
"train": 25730,
|
| 990 |
-
"validation": 28
|
| 991 |
-
|
| 992 |
-
|
| 993 |
},
|
| 994 |
-
"
|
| 995 |
-
"rows": 14714,
|
| 996 |
"authors": 2,
|
| 997 |
-
"
|
| 998 |
"sources": {
|
| 999 |
-
"agdt":
|
| 1000 |
},
|
| 1001 |
"splits": {
|
| 1002 |
-
"
|
| 1003 |
-
"
|
| 1004 |
-
"
|
| 1005 |
-
}
|
|
|
|
| 1006 |
},
|
| 1007 |
-
"
|
| 1008 |
-
"rows": 12194,
|
| 1009 |
"authors": 2,
|
| 1010 |
-
"
|
| 1011 |
"sources": {
|
| 1012 |
-
"agdt":
|
| 1013 |
},
|
| 1014 |
"splits": {
|
| 1015 |
-
"
|
| 1016 |
-
"
|
| 1017 |
-
"
|
| 1018 |
-
}
|
|
|
|
| 1019 |
},
|
| 1020 |
-
"
|
| 1021 |
-
"rows": 11942,
|
| 1022 |
"authors": 2,
|
| 1023 |
-
"
|
| 1024 |
"sources": {
|
| 1025 |
-
"agdt":
|
| 1026 |
},
|
| 1027 |
"splits": {
|
| 1028 |
-
"
|
| 1029 |
-
"
|
| 1030 |
-
"
|
| 1031 |
-
}
|
|
|
|
| 1032 |
},
|
| 1033 |
-
"
|
| 1034 |
-
"rows": 27018,
|
| 1035 |
"authors": 2,
|
| 1036 |
-
"
|
| 1037 |
"sources": {
|
| 1038 |
-
"agdt":
|
| 1039 |
},
|
| 1040 |
"splits": {
|
| 1041 |
-
"
|
| 1042 |
-
"
|
| 1043 |
-
"
|
| 1044 |
-
}
|
|
|
|
| 1045 |
},
|
| 1046 |
-
"
|
| 1047 |
-
"rows": 22338,
|
| 1048 |
"authors": 2,
|
| 1049 |
-
"
|
| 1050 |
"sources": {
|
| 1051 |
-
"agdt":
|
| 1052 |
},
|
| 1053 |
"splits": {
|
| 1054 |
-
"
|
| 1055 |
-
"
|
| 1056 |
-
"
|
| 1057 |
-
}
|
|
|
|
| 1058 |
},
|
| 1059 |
-
"
|
| 1060 |
-
"rows": 21870,
|
| 1061 |
"authors": 2,
|
| 1062 |
-
"
|
| 1063 |
"sources": {
|
| 1064 |
-
"agdt":
|
| 1065 |
},
|
| 1066 |
"splits": {
|
| 1067 |
-
"
|
| 1068 |
-
"
|
| 1069 |
-
"
|
| 1070 |
-
}
|
| 1071 |
-
|
| 1072 |
-
"checks": {
|
| 1073 |
-
"fixed_exact_evaluation_chunks": true,
|
| 1074 |
-
"complete_chunk_text_and_syllable_aggregation": true,
|
| 1075 |
-
"identifier_free_conllu_comments": true,
|
| 1076 |
-
"identifier_free_conllu_misc": true,
|
| 1077 |
-
"identical_source_rows_across_task_sizes": true,
|
| 1078 |
-
"official_conll18_loader": true,
|
| 1079 |
-
"privacy_safe_metrical_lines": true,
|
| 1080 |
-
"prose_exact_text_unique": true,
|
| 1081 |
-
"scansion_column_absent": true,
|
| 1082 |
-
"source_verse_component_exact_coverage": true,
|
| 1083 |
-
"unique_conllu_documents_checked": 50734,
|
| 1084 |
-
"unique_ids": true
|
| 1085 |
}
|
| 1086 |
}
|
| 1087 |
}
|
|
|
|
| 539 |
},
|
| 540 |
"data_files": {
|
| 541 |
"prose_1": {
|
| 542 |
+
"test": 2800,
|
| 543 |
"train": 25730,
|
| 544 |
+
"validation": 2800
|
|
|
|
| 545 |
},
|
| 546 |
"prose_10": {
|
| 547 |
+
"test": 280,
|
| 548 |
"train": 25730,
|
| 549 |
+
"validation": 280
|
|
|
|
| 550 |
},
|
| 551 |
"prose_100": {
|
| 552 |
+
"test": 28,
|
| 553 |
"train": 25730,
|
| 554 |
+
"validation": 28
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
},
|
| 556 |
"verse_metre_1": {
|
| 557 |
+
"test": 2600,
|
| 558 |
"train": 21818,
|
| 559 |
+
"validation": 2600
|
|
|
|
| 560 |
},
|
| 561 |
"verse_metre_10": {
|
| 562 |
+
"test": 260,
|
| 563 |
"train": 21818,
|
| 564 |
+
"validation": 260
|
|
|
|
| 565 |
},
|
| 566 |
"verse_metre_100": {
|
| 567 |
+
"test": 26,
|
| 568 |
"train": 21818,
|
| 569 |
+
"validation": 26
|
| 570 |
+
},
|
| 571 |
+
"verse_sentence_1": {
|
| 572 |
+
"test": 1400,
|
| 573 |
+
"train": 11914,
|
| 574 |
+
"validation": 1400
|
| 575 |
+
},
|
| 576 |
+
"verse_sentence_10": {
|
| 577 |
+
"test": 140,
|
| 578 |
+
"train": 11914,
|
| 579 |
+
"validation": 140
|
| 580 |
+
},
|
| 581 |
+
"verse_sentence_100": {
|
| 582 |
+
"test": 14,
|
| 583 |
+
"train": 11914,
|
| 584 |
+
"validation": 14
|
| 585 |
}
|
| 586 |
},
|
| 587 |
"deduplication": {
|
|
|
|
| 938 |
}
|
| 939 |
},
|
| 940 |
"validation": {
|
| 941 |
+
"checks": {
|
| 942 |
+
"complete_chunk_text_and_syllable_aggregation": true,
|
| 943 |
+
"fixed_exact_evaluation_chunks": true,
|
| 944 |
+
"identical_source_rows_across_task_sizes": true,
|
| 945 |
+
"identifier_free_conllu_comments": true,
|
| 946 |
+
"identifier_free_conllu_misc": true,
|
| 947 |
+
"json_list_text_fields": true,
|
| 948 |
+
"official_conll18_loader": true,
|
| 949 |
+
"privacy_safe_metrical_lines": true,
|
| 950 |
+
"prose_exact_text_unique": true,
|
| 951 |
+
"scansion_column_absent": true,
|
| 952 |
+
"source_verse_component_exact_coverage": true,
|
| 953 |
+
"unique_conllu_documents_checked": 50734,
|
| 954 |
+
"unique_ids": true
|
| 955 |
+
},
|
| 956 |
"prose_1": {
|
|
|
|
| 957 |
"authors": 12,
|
| 958 |
+
"rows": 31330,
|
| 959 |
"sources": {
|
| 960 |
+
"agdt": 568,
|
| 961 |
"gorman": 17977,
|
|
|
|
| 962 |
"pedalion": 2447,
|
| 963 |
+
"ud_perseus": 4306,
|
| 964 |
+
"ud_proiel": 6032
|
| 965 |
},
|
| 966 |
"splits": {
|
| 967 |
+
"test": 2800,
|
| 968 |
"train": 25730,
|
| 969 |
+
"validation": 2800
|
| 970 |
+
},
|
| 971 |
+
"works": 39
|
| 972 |
},
|
| 973 |
"prose_10": {
|
|
|
|
| 974 |
"authors": 12,
|
| 975 |
+
"rows": 26290,
|
| 976 |
"sources": {
|
| 977 |
+
"agdt": 479,
|
| 978 |
"gorman": 15088,
|
| 979 |
+
"multiple": 26,
|
| 980 |
"pedalion": 2059,
|
| 981 |
+
"ud_perseus": 3642,
|
| 982 |
+
"ud_proiel": 4996
|
|
|
|
| 983 |
},
|
| 984 |
"splits": {
|
| 985 |
+
"test": 280,
|
| 986 |
"train": 25730,
|
| 987 |
+
"validation": 280
|
| 988 |
+
},
|
| 989 |
+
"works": 65
|
| 990 |
},
|
| 991 |
"prose_100": {
|
|
|
|
| 992 |
"authors": 12,
|
| 993 |
+
"rows": 25786,
|
| 994 |
"sources": {
|
| 995 |
+
"agdt": 473,
|
| 996 |
"gorman": 14806,
|
| 997 |
+
"multiple": 16,
|
| 998 |
"pedalion": 2022,
|
| 999 |
+
"ud_perseus": 3578,
|
| 1000 |
+
"ud_proiel": 4891
|
|
|
|
| 1001 |
},
|
| 1002 |
"splits": {
|
| 1003 |
+
"test": 28,
|
| 1004 |
"train": 25730,
|
| 1005 |
+
"validation": 28
|
| 1006 |
+
},
|
| 1007 |
+
"works": 53
|
| 1008 |
},
|
| 1009 |
+
"verse_metre_1": {
|
|
|
|
| 1010 |
"authors": 2,
|
| 1011 |
+
"rows": 27018,
|
| 1012 |
"sources": {
|
| 1013 |
+
"agdt": 27018
|
| 1014 |
},
|
| 1015 |
"splits": {
|
| 1016 |
+
"test": 2600,
|
| 1017 |
+
"train": 21818,
|
| 1018 |
+
"validation": 2600
|
| 1019 |
+
},
|
| 1020 |
+
"works": 2
|
| 1021 |
},
|
| 1022 |
+
"verse_metre_10": {
|
|
|
|
| 1023 |
"authors": 2,
|
| 1024 |
+
"rows": 22338,
|
| 1025 |
"sources": {
|
| 1026 |
+
"agdt": 22338
|
| 1027 |
},
|
| 1028 |
"splits": {
|
| 1029 |
+
"test": 260,
|
| 1030 |
+
"train": 21818,
|
| 1031 |
+
"validation": 260
|
| 1032 |
+
},
|
| 1033 |
+
"works": 2
|
| 1034 |
},
|
| 1035 |
+
"verse_metre_100": {
|
|
|
|
| 1036 |
"authors": 2,
|
| 1037 |
+
"rows": 21870,
|
| 1038 |
"sources": {
|
| 1039 |
+
"agdt": 21870
|
| 1040 |
},
|
| 1041 |
"splits": {
|
| 1042 |
+
"test": 26,
|
| 1043 |
+
"train": 21818,
|
| 1044 |
+
"validation": 26
|
| 1045 |
+
},
|
| 1046 |
+
"works": 2
|
| 1047 |
},
|
| 1048 |
+
"verse_sentence_1": {
|
|
|
|
| 1049 |
"authors": 2,
|
| 1050 |
+
"rows": 14714,
|
| 1051 |
"sources": {
|
| 1052 |
+
"agdt": 14714
|
| 1053 |
},
|
| 1054 |
"splits": {
|
| 1055 |
+
"test": 1400,
|
| 1056 |
+
"train": 11914,
|
| 1057 |
+
"validation": 1400
|
| 1058 |
+
},
|
| 1059 |
+
"works": 2
|
| 1060 |
},
|
| 1061 |
+
"verse_sentence_10": {
|
|
|
|
| 1062 |
"authors": 2,
|
| 1063 |
+
"rows": 12194,
|
| 1064 |
"sources": {
|
| 1065 |
+
"agdt": 12194
|
| 1066 |
},
|
| 1067 |
"splits": {
|
| 1068 |
+
"test": 140,
|
| 1069 |
+
"train": 11914,
|
| 1070 |
+
"validation": 140
|
| 1071 |
+
},
|
| 1072 |
+
"works": 2
|
| 1073 |
},
|
| 1074 |
+
"verse_sentence_100": {
|
|
|
|
| 1075 |
"authors": 2,
|
| 1076 |
+
"rows": 11942,
|
| 1077 |
"sources": {
|
| 1078 |
+
"agdt": 11942
|
| 1079 |
},
|
| 1080 |
"splits": {
|
| 1081 |
+
"test": 14,
|
| 1082 |
+
"train": 11914,
|
| 1083 |
+
"validation": 14
|
| 1084 |
+
},
|
| 1085 |
+
"works": 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1086 |
}
|
| 1087 |
}
|
| 1088 |
}
|
scripts/build_dataset.py
CHANGED
|
@@ -31,10 +31,12 @@ import pyarrow.parquet as pq
|
|
| 31 |
try:
|
| 32 |
from scripts.dataset_variants import make_dataset_variants, variant_schema
|
| 33 |
from scripts.metrical_lines import load_public_metrical_lines, public_metrical_line
|
|
|
|
| 34 |
from scripts.vendor.conll18_ud_eval import UDError, load_conllu
|
| 35 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 36 |
from dataset_variants import make_dataset_variants, variant_schema
|
| 37 |
from metrical_lines import load_public_metrical_lines, public_metrical_line
|
|
|
|
| 38 |
from vendor.conll18_ud_eval import UDError, load_conllu
|
| 39 |
|
| 40 |
|
|
@@ -1411,6 +1413,9 @@ def validate(rows_by_config: dict[str, list[dict]]) -> dict:
|
|
| 1411 |
base_config = config.rsplit("_", 1)[0]
|
| 1412 |
assert all(row["genre"] == base_config for row in rows)
|
| 1413 |
assert all(row["text"] and row["author"] and row["work"] for row in rows)
|
|
|
|
|
|
|
|
|
|
| 1414 |
assert all(row["split"] in {"train", "validation", "test"} for row in rows)
|
| 1415 |
suffix = config.rsplit("_", 1)[1]
|
| 1416 |
if suffix != "1":
|
|
@@ -1488,9 +1493,12 @@ def validate(rows_by_config: dict[str, list[dict]]) -> dict:
|
|
| 1488 |
constituents = [
|
| 1489 |
atomic_by_id[row_id] for row_id in row["constituent_ids"]
|
| 1490 |
]
|
| 1491 |
-
|
| 1492 |
-
|
| 1493 |
-
|
|
|
|
|
|
|
|
|
|
| 1494 |
if base_config == "verse_metre":
|
| 1495 |
expected_syllables = [
|
| 1496 |
syllable
|
|
@@ -1510,6 +1518,7 @@ def validate(rows_by_config: dict[str, list[dict]]) -> dict:
|
|
| 1510 |
"identifier_free_conllu_comments": True,
|
| 1511 |
"identifier_free_conllu_misc": True,
|
| 1512 |
"privacy_safe_metrical_lines": True,
|
|
|
|
| 1513 |
}
|
| 1514 |
return report
|
| 1515 |
|
|
|
|
| 31 |
try:
|
| 32 |
from scripts.dataset_variants import make_dataset_variants, variant_schema
|
| 33 |
from scripts.metrical_lines import load_public_metrical_lines, public_metrical_line
|
| 34 |
+
from scripts.text_units import load_text_units
|
| 35 |
from scripts.vendor.conll18_ud_eval import UDError, load_conllu
|
| 36 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 37 |
from dataset_variants import make_dataset_variants, variant_schema
|
| 38 |
from metrical_lines import load_public_metrical_lines, public_metrical_line
|
| 39 |
+
from text_units import load_text_units
|
| 40 |
from vendor.conll18_ud_eval import UDError, load_conllu
|
| 41 |
|
| 42 |
|
|
|
|
| 1413 |
base_config = config.rsplit("_", 1)[0]
|
| 1414 |
assert all(row["genre"] == base_config for row in rows)
|
| 1415 |
assert all(row["text"] and row["author"] and row["work"] for row in rows)
|
| 1416 |
+
for row in rows:
|
| 1417 |
+
text_units = load_text_units(row["text"])
|
| 1418 |
+
assert len(text_units) == row.get("chunk_size", 1)
|
| 1419 |
assert all(row["split"] in {"train", "validation", "test"} for row in rows)
|
| 1420 |
suffix = config.rsplit("_", 1)[1]
|
| 1421 |
if suffix != "1":
|
|
|
|
| 1493 |
constituents = [
|
| 1494 |
atomic_by_id[row_id] for row_id in row["constituent_ids"]
|
| 1495 |
]
|
| 1496 |
+
expected_text_units = [
|
| 1497 |
+
unit
|
| 1498 |
+
for item in constituents
|
| 1499 |
+
for unit in load_text_units(item["text"])
|
| 1500 |
+
]
|
| 1501 |
+
assert load_text_units(row["text"]) == expected_text_units
|
| 1502 |
if base_config == "verse_metre":
|
| 1503 |
expected_syllables = [
|
| 1504 |
syllable
|
|
|
|
| 1518 |
"identifier_free_conllu_comments": True,
|
| 1519 |
"identifier_free_conllu_misc": True,
|
| 1520 |
"privacy_safe_metrical_lines": True,
|
| 1521 |
+
"json_list_text_fields": True,
|
| 1522 |
}
|
| 1523 |
return report
|
| 1524 |
|
scripts/dataset_variants.py
CHANGED
|
@@ -12,8 +12,10 @@ import pyarrow as pa
|
|
| 12 |
|
| 13 |
try:
|
| 14 |
from scripts.metrical_lines import load_public_metrical_lines
|
|
|
|
| 15 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 16 |
from metrical_lines import load_public_metrical_lines
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
BASE_CONFIGS = ("prose", "verse_sentence", "verse_metre")
|
|
@@ -146,6 +148,7 @@ def _provenance(row: dict) -> dict:
|
|
| 146 |
def _chunk_metadata(row: dict, target: int) -> dict:
|
| 147 |
row = dict(row)
|
| 148 |
row.update({
|
|
|
|
| 149 |
"chunk_size": 1,
|
| 150 |
"chunk_target_size": target,
|
| 151 |
"constituent_ids": [row["id"]],
|
|
@@ -205,9 +208,9 @@ def _aggregate_chunk(base_config: str, rows: list[dict], target: int, split: str
|
|
| 205 |
"id": f"chunk-{base_config}-{target}-{digest}",
|
| 206 |
"work": works[0] if not mixed_work else "Multiple works",
|
| 207 |
"work_id": work_ids[0] if not mixed_work else f"multiple:{digest}",
|
| 208 |
-
"text": (
|
| 209 |
-
|
| 210 |
-
),
|
| 211 |
"conllu": "\n\n".join(row["conllu"].strip() for row in rows) + "\n\n",
|
| 212 |
"cts_urn": rows[0]["cts_urn"] if len({row["cts_urn"] for row in rows}) == 1 else None,
|
| 213 |
"passage": (
|
|
@@ -314,7 +317,13 @@ def make_dataset_variants(
|
|
| 314 |
shared_rows, retained_authors, bottleneck_discarded = select_bottleneck_rows(
|
| 315 |
base_config, rows,
|
| 316 |
)
|
| 317 |
-
variants[f"{base_config}_1"] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
report[f"{base_config}_1"] = {
|
| 319 |
"authors": len(retained_authors),
|
| 320 |
"retained_authors": sorted(retained_authors),
|
|
|
|
| 12 |
|
| 13 |
try:
|
| 14 |
from scripts.metrical_lines import load_public_metrical_lines
|
| 15 |
+
from scripts.text_units import encode_text_units, source_text_units
|
| 16 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 17 |
from metrical_lines import load_public_metrical_lines
|
| 18 |
+
from text_units import encode_text_units, source_text_units
|
| 19 |
|
| 20 |
|
| 21 |
BASE_CONFIGS = ("prose", "verse_sentence", "verse_metre")
|
|
|
|
| 148 |
def _chunk_metadata(row: dict, target: int) -> dict:
|
| 149 |
row = dict(row)
|
| 150 |
row.update({
|
| 151 |
+
"text": encode_text_units(source_text_units(row["text"])),
|
| 152 |
"chunk_size": 1,
|
| 153 |
"chunk_target_size": target,
|
| 154 |
"constituent_ids": [row["id"]],
|
|
|
|
| 208 |
"id": f"chunk-{base_config}-{target}-{digest}",
|
| 209 |
"work": works[0] if not mixed_work else "Multiple works",
|
| 210 |
"work_id": work_ids[0] if not mixed_work else f"multiple:{digest}",
|
| 211 |
+
"text": encode_text_units([
|
| 212 |
+
unit for row in rows for unit in source_text_units(row["text"])
|
| 213 |
+
]),
|
| 214 |
"conllu": "\n\n".join(row["conllu"].strip() for row in rows) + "\n\n",
|
| 215 |
"cts_urn": rows[0]["cts_urn"] if len({row["cts_urn"] for row in rows}) == 1 else None,
|
| 216 |
"passage": (
|
|
|
|
| 317 |
shared_rows, retained_authors, bottleneck_discarded = select_bottleneck_rows(
|
| 318 |
base_config, rows,
|
| 319 |
)
|
| 320 |
+
variants[f"{base_config}_1"] = [
|
| 321 |
+
{
|
| 322 |
+
**row,
|
| 323 |
+
"text": encode_text_units(source_text_units(row["text"])),
|
| 324 |
+
}
|
| 325 |
+
for row in shared_rows
|
| 326 |
+
]
|
| 327 |
report[f"{base_config}_1"] = {
|
| 328 |
"authors": len(retained_authors),
|
| 329 |
"retained_authors": sorted(retained_authors),
|
scripts/text_units.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Canonical JSON representation for model-facing text units."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def load_text_units(encoded: str) -> list[str]:
|
| 9 |
+
"""Load a published text field and enforce a non-empty string list."""
|
| 10 |
+
units = json.loads(encoded)
|
| 11 |
+
if not isinstance(units, list) or not units:
|
| 12 |
+
raise ValueError("text must encode a non-empty JSON list")
|
| 13 |
+
if not all(isinstance(unit, str) and unit.strip() for unit in units):
|
| 14 |
+
raise ValueError("every text unit must be a non-empty string")
|
| 15 |
+
return units
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def source_text_units(value: str) -> list[str]:
|
| 19 |
+
"""Accept either an internal atomic string or published JSON text units."""
|
| 20 |
+
try:
|
| 21 |
+
return load_text_units(value)
|
| 22 |
+
except (json.JSONDecodeError, TypeError, ValueError):
|
| 23 |
+
if not isinstance(value, str) or not value.strip():
|
| 24 |
+
raise ValueError("source text must be a non-empty string")
|
| 25 |
+
return [value]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def encode_text_units(units: list[str]) -> str:
|
| 29 |
+
"""Serialize text units without losing their original strings."""
|
| 30 |
+
if not units or not all(isinstance(unit, str) and unit.strip() for unit in units):
|
| 31 |
+
raise ValueError("text units must be non-empty strings")
|
| 32 |
+
return json.dumps(units, ensure_ascii=False)
|
scripts/validate_dataset.py
CHANGED
|
@@ -26,6 +26,7 @@ try:
|
|
| 26 |
variant_schema,
|
| 27 |
)
|
| 28 |
from scripts.metrical_lines import load_public_metrical_lines
|
|
|
|
| 29 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 30 |
from dataset_variants import ( # type: ignore[no-redef]
|
| 31 |
BOTTLENECK_TARGET,
|
|
@@ -33,6 +34,7 @@ except ModuleNotFoundError: # Direct execution from the scripts directory.
|
|
| 33 |
variant_schema,
|
| 34 |
)
|
| 35 |
from metrical_lines import load_public_metrical_lines
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
BASE_CONFIGS = ("prose", "verse_sentence", "verse_metre")
|
|
@@ -221,7 +223,9 @@ def validate_metrical_line_privacy(root: Path) -> int:
|
|
| 221 |
def cumulative_lengths(rows: list[dict]) -> list[int]:
|
| 222 |
boundaries = [0]
|
| 223 |
for row in rows:
|
| 224 |
-
boundaries.append(boundaries[-1] +
|
|
|
|
|
|
|
| 225 |
return boundaries
|
| 226 |
|
| 227 |
|
|
@@ -247,8 +251,16 @@ def validate_alignment_components(configs: dict[str, list[dict]]) -> int:
|
|
| 247 |
continue
|
| 248 |
if any(not set(row["parent_sentence_ids"]) <= sentence_ids for row in lines):
|
| 249 |
continue
|
| 250 |
-
sentence_text = "".join(
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
assert sentence_text == line_text
|
| 253 |
complete_components += 1
|
| 254 |
sentence_bounds = cumulative_lengths(sentences)
|
|
@@ -318,9 +330,12 @@ def validate_variants(configs: dict[str, list[dict]]) -> None:
|
|
| 318 |
constituents = [atomic_by_id[row_id] for row_id in chunk["constituent_ids"]]
|
| 319 |
assert all(row["author"] == chunk["author"] for row in constituents)
|
| 320 |
assert all(row["split"] == split for row in constituents)
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
|
|
|
|
|
|
|
|
|
| 324 |
if base == "verse_metre":
|
| 325 |
expected_syllables = [
|
| 326 |
syllable
|
|
@@ -492,6 +507,13 @@ def main() -> None:
|
|
| 492 |
base_config = config.rsplit("_", 1)[0]
|
| 493 |
assert all(row["genre"] == base_config for row in rows)
|
| 494 |
assert all(row["text"] and row["author"] and row["work"] for row in rows)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
if base_config == "prose":
|
| 496 |
keys = [row["dedup_key"] for row in rows]
|
| 497 |
assert len(keys) == len(set(keys)), "prose is not exactly deduplicated"
|
|
|
|
| 26 |
variant_schema,
|
| 27 |
)
|
| 28 |
from scripts.metrical_lines import load_public_metrical_lines
|
| 29 |
+
from scripts.text_units import load_text_units
|
| 30 |
except ModuleNotFoundError: # Direct execution from the scripts directory.
|
| 31 |
from dataset_variants import ( # type: ignore[no-redef]
|
| 32 |
BOTTLENECK_TARGET,
|
|
|
|
| 34 |
variant_schema,
|
| 35 |
)
|
| 36 |
from metrical_lines import load_public_metrical_lines
|
| 37 |
+
from text_units import load_text_units
|
| 38 |
|
| 39 |
|
| 40 |
BASE_CONFIGS = ("prose", "verse_sentence", "verse_metre")
|
|
|
|
| 223 |
def cumulative_lengths(rows: list[dict]) -> list[int]:
|
| 224 |
boundaries = [0]
|
| 225 |
for row in rows:
|
| 226 |
+
boundaries.append(boundaries[-1] + sum(
|
| 227 |
+
len(normalize(unit)) for unit in load_text_units(row["text"])
|
| 228 |
+
))
|
| 229 |
return boundaries
|
| 230 |
|
| 231 |
|
|
|
|
| 251 |
continue
|
| 252 |
if any(not set(row["parent_sentence_ids"]) <= sentence_ids for row in lines):
|
| 253 |
continue
|
| 254 |
+
sentence_text = "".join(
|
| 255 |
+
normalize(unit)
|
| 256 |
+
for row in sentences
|
| 257 |
+
for unit in load_text_units(row["text"])
|
| 258 |
+
)
|
| 259 |
+
line_text = "".join(
|
| 260 |
+
normalize(unit)
|
| 261 |
+
for row in lines
|
| 262 |
+
for unit in load_text_units(row["text"])
|
| 263 |
+
)
|
| 264 |
assert sentence_text == line_text
|
| 265 |
complete_components += 1
|
| 266 |
sentence_bounds = cumulative_lengths(sentences)
|
|
|
|
| 330 |
constituents = [atomic_by_id[row_id] for row_id in chunk["constituent_ids"]]
|
| 331 |
assert all(row["author"] == chunk["author"] for row in constituents)
|
| 332 |
assert all(row["split"] == split for row in constituents)
|
| 333 |
+
expected_text_units = [
|
| 334 |
+
unit
|
| 335 |
+
for row in constituents
|
| 336 |
+
for unit in load_text_units(row["text"])
|
| 337 |
+
]
|
| 338 |
+
assert load_text_units(chunk["text"]) == expected_text_units
|
| 339 |
if base == "verse_metre":
|
| 340 |
expected_syllables = [
|
| 341 |
syllable
|
|
|
|
| 507 |
base_config = config.rsplit("_", 1)[0]
|
| 508 |
assert all(row["genre"] == base_config for row in rows)
|
| 509 |
assert all(row["text"] and row["author"] and row["work"] for row in rows)
|
| 510 |
+
for row in rows:
|
| 511 |
+
text_units = load_text_units(row["text"])
|
| 512 |
+
expected_units = row.get("chunk_size", 1)
|
| 513 |
+
assert len(text_units) == expected_units, (
|
| 514 |
+
f"text-unit count mismatch in {config}, row {row['id']}: "
|
| 515 |
+
f"{len(text_units)} != {expected_units}"
|
| 516 |
+
)
|
| 517 |
if base_config == "prose":
|
| 518 |
keys = [row["dedup_key"] for row in rows]
|
| 519 |
assert len(keys) == len(set(keys)), "prose is not exactly deduplicated"
|
tests/test_split_stratification.py
CHANGED
|
@@ -9,6 +9,7 @@ from scripts.metrical_lines import (
|
|
| 9 |
load_public_metrical_lines,
|
| 10 |
sanitize_metrical_lines,
|
| 11 |
)
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
DATA_ROOT = Path(__file__).resolve().parents[1] / "data"
|
|
@@ -71,7 +72,7 @@ def test_all_task_sizes_cover_exactly_the_same_atomic_rows() -> None:
|
|
| 71 |
for split in ("train", "validation", "test"):
|
| 72 |
path = DATA_ROOT / f"{base_config}_1" / f"{split}-00000-of-00001.parquet"
|
| 73 |
atomic_rows[split] = {
|
| 74 |
-
row["id"]: row["text"]
|
| 75 |
for row in pq.read_table(path, columns=["id", "text"]).to_pylist()
|
| 76 |
}
|
| 77 |
|
|
@@ -93,17 +94,33 @@ def test_all_task_sizes_cover_exactly_the_same_atomic_rows() -> None:
|
|
| 93 |
threshold,
|
| 94 |
split,
|
| 95 |
)
|
| 96 |
-
separator = "\n" if base_config == "verse_metre" else "\n\n"
|
| 97 |
for chunk in chunks:
|
| 98 |
expected_text = (
|
| 99 |
atomic_rows[split][chunk["constituent_ids"][0]]
|
| 100 |
if split == "train"
|
| 101 |
-
else
|
| 102 |
-
|
| 103 |
for row_id in chunk["constituent_ids"]
|
| 104 |
-
|
|
|
|
| 105 |
)
|
| 106 |
-
assert chunk["text"] == expected_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def test_verse_metre_chunks_concatenate_every_constituent_syllable() -> None:
|
|
|
|
| 9 |
load_public_metrical_lines,
|
| 10 |
sanitize_metrical_lines,
|
| 11 |
)
|
| 12 |
+
from scripts.text_units import load_text_units
|
| 13 |
|
| 14 |
|
| 15 |
DATA_ROOT = Path(__file__).resolve().parents[1] / "data"
|
|
|
|
| 72 |
for split in ("train", "validation", "test"):
|
| 73 |
path = DATA_ROOT / f"{base_config}_1" / f"{split}-00000-of-00001.parquet"
|
| 74 |
atomic_rows[split] = {
|
| 75 |
+
row["id"]: load_text_units(row["text"])
|
| 76 |
for row in pq.read_table(path, columns=["id", "text"]).to_pylist()
|
| 77 |
}
|
| 78 |
|
|
|
|
| 94 |
threshold,
|
| 95 |
split,
|
| 96 |
)
|
|
|
|
| 97 |
for chunk in chunks:
|
| 98 |
expected_text = (
|
| 99 |
atomic_rows[split][chunk["constituent_ids"][0]]
|
| 100 |
if split == "train"
|
| 101 |
+
else [
|
| 102 |
+
unit
|
| 103 |
for row_id in chunk["constituent_ids"]
|
| 104 |
+
for unit in atomic_rows[split][row_id]
|
| 105 |
+
]
|
| 106 |
)
|
| 107 |
+
assert load_text_units(chunk["text"]) == expected_text
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def test_text_is_json_list_with_one_entry_per_constituent() -> None:
|
| 111 |
+
for base_config in BASE_CONFIGS:
|
| 112 |
+
for suffix in ("1", "10", "100"):
|
| 113 |
+
for split in ("train", "validation", "test"):
|
| 114 |
+
path = (
|
| 115 |
+
DATA_ROOT / f"{base_config}_{suffix}"
|
| 116 |
+
/ f"{split}-00000-of-00001.parquet"
|
| 117 |
+
)
|
| 118 |
+
columns = ["text"]
|
| 119 |
+
if suffix != "1":
|
| 120 |
+
columns.append("chunk_size")
|
| 121 |
+
for row in pq.read_table(path, columns=columns).to_pylist():
|
| 122 |
+
expected = row.get("chunk_size", 1)
|
| 123 |
+
assert len(load_text_units(row["text"])) == expected
|
| 124 |
|
| 125 |
|
| 126 |
def test_verse_metre_chunks_concatenate_every_constituent_syllable() -> None:
|
tests/test_verse_character_coverage.py
CHANGED
|
@@ -3,6 +3,8 @@ import unicodedata
|
|
| 3 |
|
| 4 |
import pyarrow.parquet as pq
|
| 5 |
|
|
|
|
|
|
|
| 6 |
|
| 7 |
DATA_ROOT = Path(__file__).resolve().parents[1] / "data"
|
| 8 |
|
|
@@ -11,7 +13,8 @@ def normalized_character_count(config: str) -> int:
|
|
| 11 |
count = 0
|
| 12 |
for path in sorted((DATA_ROOT / config).glob("*.parquet")):
|
| 13 |
texts = pq.read_table(path, columns=["text"])["text"].to_pylist()
|
| 14 |
-
for
|
|
|
|
| 15 |
decomposed = unicodedata.normalize(
|
| 16 |
"NFD", text.lower().replace("ς", "σ")
|
| 17 |
)
|
|
|
|
| 3 |
|
| 4 |
import pyarrow.parquet as pq
|
| 5 |
|
| 6 |
+
from scripts.text_units import load_text_units
|
| 7 |
+
|
| 8 |
|
| 9 |
DATA_ROOT = Path(__file__).resolve().parents[1] / "data"
|
| 10 |
|
|
|
|
| 13 |
count = 0
|
| 14 |
for path in sorted((DATA_ROOT / config).glob("*.parquet")):
|
| 15 |
texts = pq.read_table(path, columns=["text"])["text"].to_pylist()
|
| 16 |
+
for encoded in texts:
|
| 17 |
+
text = "".join(load_text_units(encoded))
|
| 18 |
decomposed = unicodedata.normalize(
|
| 19 |
"NFD", text.lower().replace("ς", "σ")
|
| 20 |
)
|