@yanqirenshi/hefti 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +84 -1
  2. package/examples/editions/rich_book/01_sample/001_front.json +17 -0
  3. package/examples/editions/rich_book/01_sample/002_s1.json +127 -0
  4. package/examples/editions/rich_book/01_sample/003_s2.json +25 -0
  5. package/examples/editions/rich_book/01_sample/index.json +53 -0
  6. package/examples/editions/rich_book/02_sample/001_front.json +17 -0
  7. package/examples/editions/rich_book/02_sample/002_s1.json +123 -0
  8. package/examples/editions/rich_book/02_sample/003_s2.json +25 -0
  9. package/examples/editions/rich_book/02_sample/index.json +46 -0
  10. package/examples/editions/rich_book/original/001_front.json +17 -0
  11. package/examples/editions/rich_book/original/002_s1.json +123 -0
  12. package/examples/editions/rich_book/original/003_s2.json +25 -0
  13. package/examples/editions/rich_book/original/index.json +45 -0
  14. package/examples/invalid/index/edition_base_empty.json +124 -0
  15. package/examples/invalid/index/edition_base_number.json +124 -0
  16. package/examples/invalid/index/edition_created_at_date_only.json +124 -0
  17. package/examples/invalid/index/edition_created_at_fraction.json +124 -0
  18. package/examples/invalid/index/edition_created_at_no_offset.json +124 -0
  19. package/examples/invalid/index/edition_created_at_no_seconds.json +124 -0
  20. package/examples/invalid/index/edition_created_at_number.json +124 -0
  21. package/examples/invalid/index/edition_created_at_space.json +124 -0
  22. package/examples/invalid/index/edition_editor_empty.json +124 -0
  23. package/examples/invalid/index/edition_editor_hyphens_only.json +124 -0
  24. package/examples/invalid/index/edition_editor_number.json +124 -0
  25. package/examples/invalid/index/edition_editor_underscore.json +124 -0
  26. package/examples/invalid/index/edition_editor_uppercase.json +124 -0
  27. package/examples/invalid/index/edition_name_empty.json +124 -0
  28. package/examples/invalid/index/edition_name_number.json +124 -0
  29. package/examples/invalid/index/edition_no_base.json +123 -0
  30. package/examples/invalid/index/edition_no_created_at.json +123 -0
  31. package/examples/invalid/index/edition_no_editor.json +123 -0
  32. package/examples/invalid/index/edition_no_name.json +123 -0
  33. package/examples/invalid/index/edition_no_retired_ids.json +121 -0
  34. package/examples/invalid/index/edition_retired_ids_duplicate.json +125 -0
  35. package/examples/invalid/index/edition_retired_ids_number_item.json +125 -0
  36. package/examples/invalid/index/edition_retired_ids_string.json +122 -0
  37. package/examples/invalid/index/edition_retired_notes_number_value.json +124 -0
  38. package/examples/invalid/index/edition_retired_notes_string.json +122 -0
  39. package/examples/invalid/index/edition_string.json +113 -0
  40. package/examples/invalid/part/caption--note_no_origin.json +73 -0
  41. package/examples/invalid/part/caption--note_number.json +80 -0
  42. package/examples/invalid/part/caption--origin_ids_string.json +77 -0
  43. package/examples/invalid/part/caption--origin_no_edition.json +78 -0
  44. package/examples/invalid/part/caption--origin_text_array.json +81 -0
  45. package/examples/invalid/part/figure--notes_key_leading_zero.json +84 -0
  46. package/examples/invalid/part/figure--notes_key_letter.json +84 -0
  47. package/examples/invalid/part/figure--notes_key_negative.json +84 -0
  48. package/examples/invalid/part/figure--notes_no_origin.json +75 -0
  49. package/examples/invalid/part/figure--notes_string.json +82 -0
  50. package/examples/invalid/part/figure--notes_value_number.json +84 -0
  51. package/examples/invalid/part/figure--origin_edition_empty.json +81 -0
  52. package/examples/invalid/part/figure--origin_ids_string.json +79 -0
  53. package/examples/invalid/part/figure--origin_no_edition.json +80 -0
  54. package/examples/invalid/part/figure--origin_no_ids.json +78 -0
  55. package/examples/invalid/part/figure--origin_string.json +73 -0
  56. package/examples/invalid/part/figure--origin_text_number_item.json +81 -0
  57. package/examples/invalid/part/figure--origin_text_string.json +79 -0
  58. package/examples/invalid/part/list--item_sentence_note_no_origin.json +93 -0
  59. package/examples/invalid/part/list--item_sentence_note_number.json +100 -0
  60. package/examples/invalid/part/list--item_sentence_origin_no_ids.json +96 -0
  61. package/examples/invalid/part/list--item_sentence_origin_text_array.json +101 -0
  62. package/examples/invalid/part/paragraph--sentence_note_no_origin.json +26 -0
  63. package/examples/invalid/part/paragraph--sentence_note_number.json +33 -0
  64. package/examples/invalid/part/paragraph--sentence_origin_edition_empty.json +32 -0
  65. package/examples/invalid/part/paragraph--sentence_origin_edition_number.json +32 -0
  66. package/examples/invalid/part/paragraph--sentence_origin_ids_number_item.json +32 -0
  67. package/examples/invalid/part/paragraph--sentence_origin_ids_string.json +30 -0
  68. package/examples/invalid/part/paragraph--sentence_origin_no_edition.json +31 -0
  69. package/examples/invalid/part/paragraph--sentence_origin_no_ids.json +29 -0
  70. package/examples/invalid/part/paragraph--sentence_origin_string.json +26 -0
  71. package/examples/invalid/part/paragraph--sentence_origin_text_array.json +34 -0
  72. package/examples/invalid/part/table--cell_note_no_origin.json +87 -0
  73. package/examples/invalid/part/table--cell_note_number.json +94 -0
  74. package/examples/invalid/part/table--cell_origin_ids_string.json +91 -0
  75. package/examples/invalid/part/table--cell_origin_no_edition.json +92 -0
  76. package/examples/invalid/part/table--cell_origin_text_array.json +95 -0
  77. package/examples/valid/big_table_book/001_s1.json +27 -27
  78. package/examples/valid/big_table_book/002_s1.1.json +216 -216
  79. package/examples/valid/big_table_book/003_s1.2.json +27 -27
  80. package/examples/valid/big_table_book/004_s2.json +25 -25
  81. package/examples/valid/big_table_book/index.json +28 -28
  82. package/examples/valid/deep_book/001_s1.json +27 -27
  83. package/examples/valid/deep_book/002_s1.1.json +29 -29
  84. package/examples/valid/deep_book/003_s1.1.1.json +30 -30
  85. package/examples/valid/deep_book/004_s1.1.1.1.json +31 -31
  86. package/examples/valid/deep_book/005_s1.1.1.1.1.json +32 -32
  87. package/examples/valid/deep_book/006_s1.1.1.1.1.1.json +33 -33
  88. package/examples/valid/deep_book/007_s1.1.1.1.1.1.1.json +33 -33
  89. package/examples/valid/deep_book/index.json +69 -69
  90. package/examples/valid/empty_book/index.json +9 -9
  91. package/examples/valid/merged_table_book/001_s1.json +38 -38
  92. package/examples/valid/merged_table_book/index.json +15 -15
  93. package/examples/valid/no_heading_book/001_front.json +39 -39
  94. package/examples/valid/no_heading_book/index.json +14 -14
  95. package/examples/valid/rich_book/002_s1.json +123 -123
  96. package/examples/valid/rich_book/003_s2.json +25 -25
  97. package/examples/valid/rich_book/index.json +45 -45
  98. package/examples/valid/rich_split_book/001_front.json +17 -17
  99. package/examples/valid/rich_split_book/002_s1.json +28 -28
  100. package/examples/valid/rich_split_book/003_s1.1.json +90 -90
  101. package/examples/valid/rich_split_book/004_s1.1.1.json +28 -28
  102. package/examples/valid/rich_split_book/005_s2.json +25 -25
  103. package/examples/valid/rich_split_book/index.json +47 -47
  104. package/examples/valid/sized_book/001_front.json +17 -17
  105. package/examples/valid/sized_book/002_s1.json +51 -51
  106. package/examples/valid/sized_book/003_s1.1.json +43 -43
  107. package/examples/valid/sized_book/004_s1.1.1.json +42 -42
  108. package/examples/valid/sized_book/005_s1.2.json +28 -28
  109. package/examples/valid/sized_book/006_s2.json +64 -64
  110. package/examples/valid/sized_book/index.json +39 -39
  111. package/index.d.ts +3 -0
  112. package/index.js +168 -4
  113. package/package.json +3 -2
  114. package/schema/structure-index.schema.json +52 -0
  115. package/schema/structure-part.schema.json +116 -4
  116. package/types.d.ts +99 -0
package/index.js CHANGED
@@ -141,6 +141,9 @@ export const structureIndexSchema = {
141
141
  "items": {
142
142
  "$ref": "#/$defs/tocNode"
143
143
  }
144
+ },
145
+ "edition": {
146
+ "$ref": "#/$defs/edition"
144
147
  }
145
148
  },
146
149
  "required": [
@@ -194,6 +197,55 @@ export const structureIndexSchema = {
194
197
  "file",
195
198
  "children"
196
199
  ]
200
+ },
201
+ "edition": {
202
+ "type": "object",
203
+ "description": "この版の情報。original(OCR の結果から作る原本)には無く、original を元に直した版にある。どの版を元に、だれが、いつ作ったかと、元の版から消した ID を持つ。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
204
+ "properties": {
205
+ "name": {
206
+ "description": "版の名前。structure/ の下のフォルダの名前と同じ(例: 01_ocr-fix)。",
207
+ "type": "string",
208
+ "minLength": 1
209
+ },
210
+ "base": {
211
+ "description": "元にした版の名前(例: original)。要素の origin.edition は、この版を指す。",
212
+ "type": "string",
213
+ "minLength": 1
214
+ },
215
+ "editor": {
216
+ "description": "版を作った作業の名前。英小文字・数字・ハイフンで書く(ハイフン以外を 1 文字以上)。",
217
+ "type": "string",
218
+ "pattern": "^[a-z0-9-]*[a-z0-9][a-z0-9-]*$"
219
+ },
220
+ "created_at": {
221
+ "description": "版を作った日時(タイムゾーンつき。例: 2026-11-24T16:36:59+09:00)。",
222
+ "type": "string",
223
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|[+-][0-9]{2}:[0-9]{2})$"
224
+ },
225
+ "retired_ids": {
226
+ "description": "元の版にあって、この版では消した要素の ID の一覧(無ければ空)。版から次の版を作るときは引き継ぐ。",
227
+ "type": "array",
228
+ "uniqueItems": true,
229
+ "items": {
230
+ "description": "消した要素の ID。",
231
+ "type": "string"
232
+ }
233
+ },
234
+ "retired_notes": {
235
+ "description": "消した理由。キーは retired_ids にある ID、値は理由の文。次の版には引き継がない。",
236
+ "type": "object",
237
+ "additionalProperties": {
238
+ "type": "string"
239
+ }
240
+ }
241
+ },
242
+ "required": [
243
+ "name",
244
+ "base",
245
+ "editor",
246
+ "created_at",
247
+ "retired_ids"
248
+ ]
197
249
  }
198
250
  }
199
251
  };
@@ -330,12 +382,24 @@ export const structurePartSchema = {
330
382
  "text": {
331
383
  "description": "センテンスの本文。文末の記号(。!?)のほか、区切りの後ろの空白や改行を末尾に含むことがある。",
332
384
  "type": "string"
385
+ },
386
+ "origin": {
387
+ "$ref": "#/$defs/origin"
388
+ },
389
+ "note": {
390
+ "description": "このセンテンスを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
391
+ "type": "string"
333
392
  }
334
393
  },
335
394
  "required": [
336
395
  "id",
337
396
  "text"
338
- ]
397
+ ],
398
+ "dependentRequired": {
399
+ "note": [
400
+ "origin"
401
+ ]
402
+ }
339
403
  },
340
404
  "section": {
341
405
  "type": "object",
@@ -548,6 +612,19 @@ export const structurePartSchema = {
548
612
  },
549
613
  "source": {
550
614
  "$ref": "#/$defs/source"
615
+ },
616
+ "origin": {
617
+ "$ref": "#/$defs/figureOrigin"
618
+ },
619
+ "notes": {
620
+ "description": "図の中の文字ごとの、直した理由。キーは text の何番目か(0 から)、値は理由の文。origin があるときだけ付く。",
621
+ "type": "object",
622
+ "propertyNames": {
623
+ "pattern": "^(0|[1-9][0-9]*)$"
624
+ },
625
+ "additionalProperties": {
626
+ "type": "string"
627
+ }
551
628
  }
552
629
  },
553
630
  "required": [
@@ -556,7 +633,12 @@ export const structurePartSchema = {
556
633
  "src",
557
634
  "text",
558
635
  "source"
559
- ]
636
+ ],
637
+ "dependentRequired": {
638
+ "notes": [
639
+ "origin"
640
+ ]
641
+ }
560
642
  },
561
643
  "caption": {
562
644
  "type": "object",
@@ -577,6 +659,13 @@ export const structurePartSchema = {
577
659
  },
578
660
  "source": {
579
661
  "$ref": "#/$defs/source"
662
+ },
663
+ "origin": {
664
+ "$ref": "#/$defs/origin"
665
+ },
666
+ "note": {
667
+ "description": "この図表の説明を元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
668
+ "type": "string"
580
669
  }
581
670
  },
582
671
  "required": [
@@ -584,7 +673,12 @@ export const structurePartSchema = {
584
673
  "id",
585
674
  "text",
586
675
  "source"
587
- ]
676
+ ],
677
+ "dependentRequired": {
678
+ "note": [
679
+ "origin"
680
+ ]
681
+ }
588
682
  },
589
683
  "table": {
590
684
  "type": "object",
@@ -645,6 +739,13 @@ export const structurePartSchema = {
645
739
  "text": {
646
740
  "description": "セルの本文。",
647
741
  "type": "string"
742
+ },
743
+ "origin": {
744
+ "$ref": "#/$defs/origin"
745
+ },
746
+ "note": {
747
+ "description": "このセルを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
748
+ "type": "string"
648
749
  }
649
750
  },
650
751
  "required": [
@@ -653,7 +754,12 @@ export const structurePartSchema = {
653
754
  "row_span",
654
755
  "col_span",
655
756
  "text"
656
- ]
757
+ ],
758
+ "dependentRequired": {
759
+ "note": [
760
+ "origin"
761
+ ]
762
+ }
657
763
  }
658
764
  },
659
765
  "source": {
@@ -688,6 +794,64 @@ export const structurePartSchema = {
688
794
  "$ref": "#/$defs/table"
689
795
  }
690
796
  ]
797
+ },
798
+ "origin": {
799
+ "type": "object",
800
+ "description": "この要素が、元の版のどの要素から来たか。edition は元の版の名前、ids は元の要素の ID(足した文は空)、text は元の本文(足した文では付けない)。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
801
+ "properties": {
802
+ "edition": {
803
+ "description": "元の版の名前(index.json の edition.base と同じ)。",
804
+ "type": "string",
805
+ "minLength": 1
806
+ },
807
+ "ids": {
808
+ "description": "元の版の要素の ID の一覧。足した文は空。分けた文は、元の文の ID を持つ。表のセルでは、表の ID。",
809
+ "type": "array",
810
+ "items": {
811
+ "description": "元の版の要素の ID。",
812
+ "type": "string"
813
+ }
814
+ },
815
+ "text": {
816
+ "description": "元の版の本文。足した文では付けない。",
817
+ "type": "string"
818
+ }
819
+ },
820
+ "required": [
821
+ "edition",
822
+ "ids"
823
+ ]
824
+ },
825
+ "figureOrigin": {
826
+ "type": "object",
827
+ "description": "図が、元の版のどの図から来たか。origin と同じ形だが、図の text が配列なので、text も文字列の配列になる。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
828
+ "properties": {
829
+ "edition": {
830
+ "description": "元の版の名前(index.json の edition.base と同じ)。",
831
+ "type": "string",
832
+ "minLength": 1
833
+ },
834
+ "ids": {
835
+ "description": "元の版の図の ID の一覧。",
836
+ "type": "array",
837
+ "items": {
838
+ "description": "元の版の要素の ID。",
839
+ "type": "string"
840
+ }
841
+ },
842
+ "text": {
843
+ "description": "元の版の図の中の文字(図の text と同じ、文字列の配列)。",
844
+ "type": "array",
845
+ "items": {
846
+ "description": "図の中の 1 まとまりの文字。",
847
+ "type": "string"
848
+ }
849
+ }
850
+ },
851
+ "required": [
852
+ "edition",
853
+ "ids"
854
+ ]
691
855
  }
692
856
  }
693
857
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanqirenshi/hefti",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "JSON Schema for structured book JSON (structure/<edition>/): index.json and the per-section part files",
5
5
  "keywords": [
6
6
  "json-schema",
@@ -37,7 +37,8 @@
37
37
  },
38
38
  "scripts": {
39
39
  "build": "node scripts/build-index.mjs && node scripts/build-types.mjs",
40
- "test": "node --test"
40
+ "test": "node --test",
41
+ "prepublishOnly": "npm test"
41
42
  },
42
43
  "devDependencies": {
43
44
  "ajv": "^8.17.1",
@@ -138,6 +138,9 @@
138
138
  "items": {
139
139
  "$ref": "#/$defs/tocNode"
140
140
  }
141
+ },
142
+ "edition": {
143
+ "$ref": "#/$defs/edition"
141
144
  }
142
145
  },
143
146
  "required": [
@@ -191,6 +194,55 @@
191
194
  "file",
192
195
  "children"
193
196
  ]
197
+ },
198
+ "edition": {
199
+ "type": "object",
200
+ "description": "この版の情報。original(OCR の結果から作る原本)には無く、original を元に直した版にある。どの版を元に、だれが、いつ作ったかと、元の版から消した ID を持つ。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
201
+ "properties": {
202
+ "name": {
203
+ "description": "版の名前。structure/ の下のフォルダの名前と同じ(例: 01_ocr-fix)。",
204
+ "type": "string",
205
+ "minLength": 1
206
+ },
207
+ "base": {
208
+ "description": "元にした版の名前(例: original)。要素の origin.edition は、この版を指す。",
209
+ "type": "string",
210
+ "minLength": 1
211
+ },
212
+ "editor": {
213
+ "description": "版を作った作業の名前。英小文字・数字・ハイフンで書く(ハイフン以外を 1 文字以上)。",
214
+ "type": "string",
215
+ "pattern": "^[a-z0-9-]*[a-z0-9][a-z0-9-]*$"
216
+ },
217
+ "created_at": {
218
+ "description": "版を作った日時(タイムゾーンつき。例: 2026-11-24T16:36:59+09:00)。",
219
+ "type": "string",
220
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|[+-][0-9]{2}:[0-9]{2})$"
221
+ },
222
+ "retired_ids": {
223
+ "description": "元の版にあって、この版では消した要素の ID の一覧(無ければ空)。版から次の版を作るときは引き継ぐ。",
224
+ "type": "array",
225
+ "uniqueItems": true,
226
+ "items": {
227
+ "description": "消した要素の ID。",
228
+ "type": "string"
229
+ }
230
+ },
231
+ "retired_notes": {
232
+ "description": "消した理由。キーは retired_ids にある ID、値は理由の文。次の版には引き継がない。",
233
+ "type": "object",
234
+ "additionalProperties": {
235
+ "type": "string"
236
+ }
237
+ }
238
+ },
239
+ "required": [
240
+ "name",
241
+ "base",
242
+ "editor",
243
+ "created_at",
244
+ "retired_ids"
245
+ ]
194
246
  }
195
247
  }
196
248
  }
@@ -129,12 +129,24 @@
129
129
  "text": {
130
130
  "description": "センテンスの本文。文末の記号(。!?)のほか、区切りの後ろの空白や改行を末尾に含むことがある。",
131
131
  "type": "string"
132
+ },
133
+ "origin": {
134
+ "$ref": "#/$defs/origin"
135
+ },
136
+ "note": {
137
+ "description": "このセンテンスを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
138
+ "type": "string"
132
139
  }
133
140
  },
134
141
  "required": [
135
142
  "id",
136
143
  "text"
137
- ]
144
+ ],
145
+ "dependentRequired": {
146
+ "note": [
147
+ "origin"
148
+ ]
149
+ }
138
150
  },
139
151
  "section": {
140
152
  "type": "object",
@@ -347,6 +359,19 @@
347
359
  },
348
360
  "source": {
349
361
  "$ref": "#/$defs/source"
362
+ },
363
+ "origin": {
364
+ "$ref": "#/$defs/figureOrigin"
365
+ },
366
+ "notes": {
367
+ "description": "図の中の文字ごとの、直した理由。キーは text の何番目か(0 から)、値は理由の文。origin があるときだけ付く。",
368
+ "type": "object",
369
+ "propertyNames": {
370
+ "pattern": "^(0|[1-9][0-9]*)$"
371
+ },
372
+ "additionalProperties": {
373
+ "type": "string"
374
+ }
350
375
  }
351
376
  },
352
377
  "required": [
@@ -355,7 +380,12 @@
355
380
  "src",
356
381
  "text",
357
382
  "source"
358
- ]
383
+ ],
384
+ "dependentRequired": {
385
+ "notes": [
386
+ "origin"
387
+ ]
388
+ }
359
389
  },
360
390
  "caption": {
361
391
  "type": "object",
@@ -376,6 +406,13 @@
376
406
  },
377
407
  "source": {
378
408
  "$ref": "#/$defs/source"
409
+ },
410
+ "origin": {
411
+ "$ref": "#/$defs/origin"
412
+ },
413
+ "note": {
414
+ "description": "この図表の説明を元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
415
+ "type": "string"
379
416
  }
380
417
  },
381
418
  "required": [
@@ -383,7 +420,12 @@
383
420
  "id",
384
421
  "text",
385
422
  "source"
386
- ]
423
+ ],
424
+ "dependentRequired": {
425
+ "note": [
426
+ "origin"
427
+ ]
428
+ }
387
429
  },
388
430
  "table": {
389
431
  "type": "object",
@@ -444,6 +486,13 @@
444
486
  "text": {
445
487
  "description": "セルの本文。",
446
488
  "type": "string"
489
+ },
490
+ "origin": {
491
+ "$ref": "#/$defs/origin"
492
+ },
493
+ "note": {
494
+ "description": "このセルを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。",
495
+ "type": "string"
447
496
  }
448
497
  },
449
498
  "required": [
@@ -452,7 +501,12 @@
452
501
  "row_span",
453
502
  "col_span",
454
503
  "text"
455
- ]
504
+ ],
505
+ "dependentRequired": {
506
+ "note": [
507
+ "origin"
508
+ ]
509
+ }
456
510
  }
457
511
  },
458
512
  "source": {
@@ -487,6 +541,64 @@
487
541
  "$ref": "#/$defs/table"
488
542
  }
489
543
  ]
544
+ },
545
+ "origin": {
546
+ "type": "object",
547
+ "description": "この要素が、元の版のどの要素から来たか。edition は元の版の名前、ids は元の要素の ID(足した文は空)、text は元の本文(足した文では付けない)。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
548
+ "properties": {
549
+ "edition": {
550
+ "description": "元の版の名前(index.json の edition.base と同じ)。",
551
+ "type": "string",
552
+ "minLength": 1
553
+ },
554
+ "ids": {
555
+ "description": "元の版の要素の ID の一覧。足した文は空。分けた文は、元の文の ID を持つ。表のセルでは、表の ID。",
556
+ "type": "array",
557
+ "items": {
558
+ "description": "元の版の要素の ID。",
559
+ "type": "string"
560
+ }
561
+ },
562
+ "text": {
563
+ "description": "元の版の本文。足した文では付けない。",
564
+ "type": "string"
565
+ }
566
+ },
567
+ "required": [
568
+ "edition",
569
+ "ids"
570
+ ]
571
+ },
572
+ "figureOrigin": {
573
+ "type": "object",
574
+ "description": "図が、元の版のどの図から来たか。origin と同じ形だが、図の text が配列なので、text も文字列の配列になる。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。",
575
+ "properties": {
576
+ "edition": {
577
+ "description": "元の版の名前(index.json の edition.base と同じ)。",
578
+ "type": "string",
579
+ "minLength": 1
580
+ },
581
+ "ids": {
582
+ "description": "元の版の図の ID の一覧。",
583
+ "type": "array",
584
+ "items": {
585
+ "description": "元の版の要素の ID。",
586
+ "type": "string"
587
+ }
588
+ },
589
+ "text": {
590
+ "description": "元の版の図の中の文字(図の text と同じ、文字列の配列)。",
591
+ "type": "array",
592
+ "items": {
593
+ "description": "図の中の 1 まとまりの文字。",
594
+ "type": "string"
595
+ }
596
+ }
597
+ },
598
+ "required": [
599
+ "edition",
600
+ "ids"
601
+ ]
490
602
  }
491
603
  }
492
604
  }
package/types.d.ts CHANGED
@@ -47,6 +47,7 @@ export interface StructureIndex {
47
47
  * 全セクションの目次(最上位のセクションから始まる木)。
48
48
  */
49
49
  toc: TocNode[];
50
+ edition?: Edition;
50
51
  [k: string]: unknown;
51
52
  }
52
53
  /**
@@ -126,6 +127,40 @@ export interface TocNode {
126
127
  children: TocNode[];
127
128
  [k: string]: unknown;
128
129
  }
130
+ /**
131
+ * この版の情報。original(OCR の結果から作る原本)には無く、original を元に直した版にある。どの版を元に、だれが、いつ作ったかと、元の版から消した ID を持つ。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。
132
+ */
133
+ export interface Edition {
134
+ /**
135
+ * 版の名前。structure/ の下のフォルダの名前と同じ(例: 01_ocr-fix)。
136
+ */
137
+ name: string;
138
+ /**
139
+ * 元にした版の名前(例: original)。要素の origin.edition は、この版を指す。
140
+ */
141
+ base: string;
142
+ /**
143
+ * 版を作った作業の名前。英小文字・数字・ハイフンで書く(ハイフン以外を 1 文字以上)。
144
+ */
145
+ editor: string;
146
+ /**
147
+ * 版を作った日時(タイムゾーンつき。例: 2026-11-24T16:36:59+09:00)。
148
+ */
149
+ created_at: string;
150
+ /**
151
+ * 元の版にあって、この版では消した要素の ID の一覧(無ければ空)。版から次の版を作るときは引き継ぐ。
152
+ *
153
+ * Items: 消した要素の ID。
154
+ */
155
+ retired_ids: string[];
156
+ /**
157
+ * 消した理由。キーは retired_ids にある ID、値は理由の文。次の版には引き継がない。
158
+ */
159
+ retired_notes?: {
160
+ [k: string]: string;
161
+ };
162
+ [k: string]: unknown;
163
+ }
129
164
 
130
165
  /**
131
166
  * 書籍の構造化 JSON(structure/<版>/)の、セクション単位のファイル(001_front.json、002_s1.json など)の形式。本文を「セクション(入れ子)→ パラグラフ → センテンス」で持ち、各要素に ID と元ページへの参照(source)がある。子セクションを別のファイルに分けたときは、section_ref で参照する。最初の見出しより前の本文のファイル(id が null)は、body に本文の要素が直接並ぶ。それ以外のファイルは、body が section 1 つ。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。このスキーマでは確かめられない約束(ID が structure/ 全体で重複しない、section_ref の先のファイルがある、index.json の files と実際のファイルが合う、など)は、読み込む側のプログラムが確かめます。
@@ -215,6 +250,31 @@ export interface Sentence {
215
250
  * センテンスの本文。文末の記号(。!?)のほか、区切りの後ろの空白や改行を末尾に含むことがある。
216
251
  */
217
252
  text: string;
253
+ origin?: Origin;
254
+ /**
255
+ * このセンテンスを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。
256
+ */
257
+ note?: string;
258
+ [k: string]: unknown;
259
+ }
260
+ /**
261
+ * この要素が、元の版のどの要素から来たか。edition は元の版の名前、ids は元の要素の ID(足した文は空)、text は元の本文(足した文では付けない)。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。
262
+ */
263
+ export interface Origin {
264
+ /**
265
+ * 元の版の名前(index.json の edition.base と同じ)。
266
+ */
267
+ edition: string;
268
+ /**
269
+ * 元の版の要素の ID の一覧。足した文は空。分けた文は、元の文の ID を持つ。表のセルでは、表の ID。
270
+ *
271
+ * Items: 元の版の要素の ID。
272
+ */
273
+ ids: string[];
274
+ /**
275
+ * 元の版の本文。足した文では付けない。
276
+ */
277
+ text?: string;
218
278
  [k: string]: unknown;
219
279
  }
220
280
  /**
@@ -274,6 +334,35 @@ export interface Figure {
274
334
  */
275
335
  text: string[];
276
336
  source: Source;
337
+ origin?: FigureOrigin;
338
+ /**
339
+ * 図の中の文字ごとの、直した理由。キーは text の何番目か(0 から)、値は理由の文。origin があるときだけ付く。
340
+ */
341
+ notes?: {
342
+ [k: string]: string;
343
+ };
344
+ [k: string]: unknown;
345
+ }
346
+ /**
347
+ * 図が、元の版のどの図から来たか。origin と同じ形だが、図の text が配列なので、text も文字列の配列になる。知らないプロパティは許します。後工程が要素に情報を足して別の JSON にできるようにするためです(additionalProperties は false にしません)。
348
+ */
349
+ export interface FigureOrigin {
350
+ /**
351
+ * 元の版の名前(index.json の edition.base と同じ)。
352
+ */
353
+ edition: string;
354
+ /**
355
+ * 元の版の図の ID の一覧。
356
+ *
357
+ * Items: 元の版の要素の ID。
358
+ */
359
+ ids: string[];
360
+ /**
361
+ * 元の版の図の中の文字(図の text と同じ、文字列の配列)。
362
+ *
363
+ * Items: 図の中の 1 まとまりの文字。
364
+ */
365
+ text?: string[];
277
366
  [k: string]: unknown;
278
367
  }
279
368
  /**
@@ -293,6 +382,11 @@ export interface Caption {
293
382
  */
294
383
  text: string;
295
384
  source: Source;
385
+ origin?: Origin;
386
+ /**
387
+ * この図表の説明を元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。
388
+ */
389
+ note?: string;
296
390
  [k: string]: unknown;
297
391
  }
298
392
  /**
@@ -346,6 +440,11 @@ export interface Cell {
346
440
  * セルの本文。
347
441
  */
348
442
  text: string;
443
+ origin?: Origin;
444
+ /**
445
+ * このセルを元の版から直した理由。origin があるときだけ付く。空の文字列でもよい。
446
+ */
447
+ note?: string;
349
448
  [k: string]: unknown;
350
449
  }
351
450
  /**