interslavic-oss commited on
Commit
8a49bd9
·
verified ·
1 Parent(s): daf4a2e

Initial upload: Interslavic MT corpus with monolingual data and documentation

Browse files
.gitignore ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Virtual environment
2
+ .venv/
3
+ venv/
4
+ env/
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.so
11
+ .Python
12
+ *.egg-info/
13
+ .eggs/
14
+ dist/
15
+ build/
16
+
17
+ # Environment
18
+ .env
19
+ .env.*
20
+ !.env.example
21
+
22
+ # OS
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # IDE (optional)
27
+ .idea/
28
+ .vscode/
29
+ *.swp
30
+ *.swo
31
+
32
+ # Logs and temp
33
+ *.log
34
+ *.tmp
35
+ .cache/
.hfignore ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Virtual environment
2
+ .venv
3
+ .venv/**
4
+ venv
5
+ venv/**
6
+ env
7
+ env/**
8
+
9
+ # Git
10
+ .git
11
+ .git/**
12
+ .gitignore
13
+
14
+ # Python
15
+ __pycache__/
16
+ *.py[cod]
17
+ *$py.class
18
+ *.so
19
+ .Python
20
+ *.egg-info/
21
+ .eggs/
22
+ dist/
23
+ build/
24
+
25
+ # Environment
26
+ .env
27
+ .env.*
28
+ !.env.example
29
+
30
+ # OS
31
+ .DS_Store
32
+ Thumbs.db
33
+
34
+ # IDE
35
+ .idea/
36
+ .vscode/
37
+ *.swp
38
+ *.swo
39
+
40
+ # Logs and temp
41
+ *.log
42
+ *.tmp
43
+ .cache/
CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+
11
+ - Initial repo structure: `monolingual/`, `parallel/`, `scripts/`.
12
+ - `monolingual/isv_sentences.parquet` with schema `id`, `sentence`, `source` and a small initial set of sentences (source: nnnbo).
13
+ - `scripts/validate_corpus.py` for format and referential validation.
14
+ - README, CONTRIBUTING, LICENSE (ISLF Open Data License v1.0), LICENSE-CODE (MIT), DATA-USE-AGREEMENT.
CONTRIBUTING.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to Interslavic MT Data
2
+
3
+ Thank you for contributing. This repo is data-only: we accept contributions to the **monolingual** and **parallel** corpora, following the formats below.
4
+
5
+ ---
6
+
7
+ ## Repo layout
8
+
9
+ - **monolingual/isv_sentences.parquet** — Single source of truth for Interslavic sentences. Do not add rows that have not been verified.
10
+ - **parallel/** — One Parquet file per language pair, e.g. `isv-eng.parquet`, `isv-rus.parquet`.
11
+
12
+ ---
13
+
14
+ ## Monolingual schema
15
+
16
+ | Column | Type | Description |
17
+ |----------|--------|-------------|
18
+ | `id` | string | Unique id (e.g. `isv-0001`). Must be unique across the file. |
19
+ | `sentence` | string | The Interslavic sentence. |
20
+ | `source` | string | Source identifier; each value maps to a documented license (see SOURCES.md or CONTRIBUTING). |
21
+
22
+ - No duplicate `id`s.
23
+ - No nulls in `id`, `sentence`, or `source`.
24
+
25
+ ---
26
+
27
+ ## Parallel schema
28
+
29
+ | Column | Type | Description |
30
+ |----------------|--------|-------------|
31
+ | `id` | string | Must exist in `monolingual/isv_sentences.parquet`. |
32
+ | `isv` | string | Must match the `sentence` for that `id` in the monolingual file exactly. |
33
+ | `target` | string | Translation in the target language. |
34
+ | `translator` | string | Who provided the translation (person or system). |
35
+ | `method` | string | One of: `human`, `machine_raw`, `machine_postedited`. |
36
+ | `review_status`| string | e.g. `unreviewed`, `approved`, `rejected`. |
37
+
38
+ - Every `id` must exist in the monolingual dataset.
39
+ - `isv` must match the monolingual sentence for that `id` exactly (no whitespace or normalization differences).
40
+
41
+ ---
42
+
43
+ ## Workflow
44
+
45
+ 1. Add or edit rows in `parallel/isv-{lang}.parquet` (or add a new pair file with the same schema).
46
+ 2. Ensure each row references an existing `id` from the monolingual set and that `isv` matches.
47
+ 3. Set `method` and `review_status` appropriately (e.g. `unreviewed` for new submissions).
48
+ 4. Run `python scripts/validate_corpus.py` before committing; fix any format errors.
49
+ 5. ISLF maintainers will review when needed.
50
+
51
+ Adding new sentences to the **monolingual** set is done in coordination with maintainers so that sources and licenses are documented.
52
+
53
+ ---
54
+
55
+ ## License per source
56
+
57
+ Each `source` value in the monolingual file corresponds to one documented license. Contributors must have rights to contribute under that license; by submitting, you confirm that. We do not mix incompatible licenses into one work — see LICENSE.md.
DATA-USE-AGREEMENT.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data Use Agreement — Summary
2
+
3
+ This document summarizes your obligations when using data from this repository. **These are LICENSE CONDITIONS, not optional guidelines.** Full terms are in [LICENSE.md](LICENSE.md).
4
+
5
+ ---
6
+
7
+ ## The One Rule
8
+
9
+ **If you build a model that outputs Interslavic using this data, you MUST either:**
10
+
11
+ 1. **Get ISLF certification** — then you can use the "Certified by ISLF" mark, OR
12
+
13
+ 2. **Display the mandatory disclaimer** — everywhere the model is published or used:
14
+
15
+ > **WARNING: This model is NOT certified by the InterSlavic Linguistic Forum. The Interslavic output may be incorrect, unnatural, or misleading. Do not rely on this model for accurate Interslavic.**
16
+
17
+ **There is no third option.**
18
+
19
+ ---
20
+
21
+ ## What counts as a violation?
22
+
23
+ - Publishing an uncertified model without the disclaimer
24
+ - Hiding, minimizing, or removing the disclaimer
25
+ - Claiming or implying ISLF endorsement for an uncertified model
26
+ - Distributing a fork that removes the disclaimer
27
+ - Any attempt to circumvent these requirements
28
+
29
+ ---
30
+
31
+ ## Consequences of violation
32
+
33
+ 1. Your license to use this data **terminates automatically**
34
+ 2. ISLF may **publicly identify** your model as non-compliant
35
+ 3. ISLF may **demand takedown** of non-compliant distributions
36
+ 4. ISLF may pursue **legal action** under Polish law
37
+
38
+ You have **14 days** to cure a first-time violation after notification. Repeat violations = permanent ban.
39
+
40
+ ---
41
+
42
+ ## For downstream users / forks
43
+
44
+ **These terms apply to you too.** The ShareAlike clause in LICENSE.md means everyone who receives this data — directly or through forks — is bound by the same conditions. You cannot fork the data and remove the certification requirement.
45
+
46
+ ---
47
+
48
+ ## Why?
49
+
50
+ Low-quality "Interslavic" models harm users and the language community. This policy ensures that:
51
+ - **Good models** get recognized (certification)
52
+ - **Work-in-progress models** are clearly labeled (disclaimer)
53
+ - **No one gets misled** about what they're getting
54
+
55
+ Certification is free. Email interslavicforum@gmail.com to start the process.
56
+
57
+ ---
58
+
59
+ ## Quick reference
60
+
61
+ | Situation | Required action |
62
+ |-----------|-----------------|
63
+ | Model is ISLF-certified | Use "Certified by ISLF" mark |
64
+ | Model is NOT certified | Display mandatory disclaimer |
65
+ | Fork of uncertified model | Keep the disclaimer |
66
+ | Want to remove disclaimer | Get certified first |
67
+
68
+ ---
69
+
70
+ **Full license:** [LICENSE.md](LICENSE.md)
71
+ **Questions / Certification:** interslavicforum@gmail.com (response within 30 days, free)
LICENSE.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ISLF Open Data License v1.0
2
+
3
+ ---
4
+
5
+ ## 1. Definitions
6
+
7
+ - **"ISLF"** means the InterSlavic Linguistic Forum Foundation (Fundacja „MiędzySłowiańskie Forum Językowe").
8
+ - **"Licensed Data"** means the data, corpora, or datasets explicitly made available under this license by the Licensor.
9
+ - **"Licensor"** means the person or entity offering the Licensed Data under this license.
10
+ - **"Derivative Work"** means any work based on or incorporating the Licensed Data, including modified versions, translations, subsets, and recombinations.
11
+ - **"Model"** means any machine learning model, system, or application that was trained, fine-tuned, or otherwise developed using the Licensed Data and produces Interslavic language output. For multi-language models, the obligations of this license apply specifically to the Interslavic language output and its associated interfaces, not to the model's output in other languages.
12
+ - **"Certified"** means ISLF has issued written confirmation that a specific Model Version meets ISLF quality standards for Interslavic language output.
13
+ - **"Model Version"** means a specific set of model weights, identified by version number, commit hash, or equivalent identifier. Any modification to model weights — including but not limited to fine-tuning, merging, quantization, distillation, or continued training — produces a new Model Version.
14
+
15
+ ---
16
+
17
+ ## 2. Grant of Rights
18
+
19
+ Subject to the terms of this license, the Licensor grants you a worldwide, royalty-free, non-exclusive license to:
20
+
21
+ - **Use** the Licensed Data for any purpose, including commercial use
22
+ - **Modify** the Licensed Data and create Derivative Works
23
+ - **Distribute** the Licensed Data and Derivative Works
24
+ - **Train machine learning models** on the Licensed Data
25
+
26
+ ---
27
+
28
+ ## 3. Conditions
29
+
30
+ Your rights under Section 2 are subject to ALL of the following conditions:
31
+
32
+ ### 3.1 Attribution
33
+
34
+ You must give appropriate credit to the Licensor in any publication, model card, or documentation that uses the Licensed Data, in the manner specified by the Licensor.
35
+
36
+ ### 3.2 ShareAlike
37
+
38
+ If you distribute the Licensed Data or Derivative Works, you must do so under this same license (ISLF Open Data License v1.0) or a later version published by ISLF. You may not apply additional restrictions that prevent recipients from exercising their rights under this license, except as required by Section 3.3.
39
+
40
+ ### 3.3 Model Certification Requirement (MANDATORY)
41
+
42
+ **This section applies to any Model that produces Interslavic language output and was trained, fine-tuned, or otherwise developed using the Licensed Data.**
43
+
44
+ **(a) Certification scope:** Certification applies to a specific Model Version. A new Model Version (as defined in Section 1) requires new certification. Until recertified, a modified Model Version is considered uncertified.
45
+
46
+ **(b) Certified Models:** Model Versions that have received written certification from ISLF may display the "Certified by ISLF" mark and are not required to display a disclaimer.
47
+
48
+ **(c) Uncertified Models:** Any Model Version that has NOT received ISLF certification MUST:
49
+
50
+ 1. Display a **prominent, unremovable disclaimer** in ALL of the following locations:
51
+ - Model card or README
52
+ - Any download page or distribution channel
53
+ - Within the application UI where the Model's Interslavic output is shown to users
54
+
55
+ 2. The disclaimer must convey substantially:
56
+ > **WARNING: This model is NOT certified by the InterSlavic Linguistic Forum. The Interslavic output may be incorrect, unnatural, or misleading. Do not rely on this model for accurate Interslavic.**
57
+
58
+ 3. The disclaimer must be in a language the end user understands.
59
+
60
+ **(d) No false endorsement:** You must NOT market, advertise, or present an uncertified Model as reliable, official, or endorsed Interslavic. You must not imply ISLF approval where none exists.
61
+
62
+ **(e) Derivatives and downstream use:** This Section 3.3 applies to ALL downstream users, forks, and Derivative Works. Removing or obscuring the disclaimer from an uncertified Model is a license violation.
63
+
64
+ ---
65
+
66
+ ## 4. Multi-Source Data
67
+
68
+ If the Licensed Data aggregates material from multiple sources with their own license terms, the Licensor must document per-source licensing in accompanying documentation (e.g., a SOURCES file).
69
+
70
+ **In the event of a conflict between this license and a source's original license, the source's original license takes precedence for data from that source.** Users must comply with both this license and any applicable source-specific terms.
71
+
72
+ Content originally produced by the Licensor carries no additional restrictions beyond this license.
73
+
74
+ ---
75
+
76
+ ## 5. Use of ISLF Name and Certification Mark
77
+
78
+ This license does not grant any trademark rights. ISLF does not claim trademark ownership over its name or the "Certified by ISLF" mark.
79
+
80
+ However, as a condition of this license, you may use the name "ISLF," the name "InterSlavic Linguistic Forum," or the phrase "Certified by ISLF" only in the following ways:
81
+
82
+ - To satisfy attribution requirements under Section 3.1
83
+ - To display the "Certified by ISLF" mark on Model Versions that have received valid certification under Section 3.3(b)
84
+ - To display the required disclaimer for uncertified Models under Section 3.3(c)
85
+ - To make truthful, factual statements about the origin of the Licensed Data or the certification status of a Model
86
+
87
+ You must NOT use the ISLF name or certification mark in any way that falsely suggests ISLF endorsement, approval, or affiliation. Unauthorized or misleading use of these terms constitutes a violation of this license and is subject to termination under Section 6.
88
+
89
+ ---
90
+
91
+ ## 6. Termination
92
+
93
+ ### 6.1 Automatic Termination
94
+
95
+ Your rights under this license terminate automatically if you fail to comply with any condition in Section 3 or Section 5. Upon termination, you must cease all use and distribution of the Licensed Data.
96
+
97
+ ### 6.2 Cure Period
98
+
99
+ If you cure a violation within **14 days** of becoming aware of it (or being notified by ISLF), your rights are reinstated. Repeat violations may result in permanent termination at ISLF's discretion.
100
+
101
+ ### 6.3 Enforcement
102
+
103
+ ISLF reserves the right to:
104
+ - Publicly identify non-compliant Models and parties
105
+ - Demand removal of non-compliant distributions
106
+ - Pursue legal remedies for license violations
107
+
108
+ ---
109
+
110
+ ## 7. Disclaimer of Warranty
111
+
112
+ THE LICENSED DATA IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE LICENSOR AND ISLF DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
113
+
114
+ ---
115
+
116
+ ## 8. Limitation of Liability
117
+
118
+ IN NO EVENT SHALL THE LICENSOR OR ISLF BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE LICENSED DATA, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119
+
120
+ ---
121
+
122
+ ## 9. Governing Law
123
+
124
+ This license is governed by Polish law. Disputes shall be resolved in courts of Poland.
125
+
126
+ ---
127
+
128
+ **Version:** 1.0
129
+ **Effective date:** February 2026
130
+ **Contact:** interslavicforum@gmail.com
131
+ **Certification requests:** Email ISLF. Free of charge. Response within 30 days.
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - isv
4
+ license: other
5
+ license_name: islf-open-data-license-v1.0
6
+ license_link: LICENSE.md
7
+ task_categories:
8
+ - translation
9
+ tags:
10
+ - interslavic
11
+ - slavic
12
+ - parallel-corpus
13
+ - machine-translation
14
+ pretty_name: Interslavic MT Data
15
+ size_categories:
16
+ - n<1K
17
+ ---
18
+
19
+ # Interslavic MT Data
20
+
21
+ A **data-only** repository: the canonical parallel corpus for training machine translation involving Interslavic. Maintained by the InterSlavic Linguistic Forum Foundation (ISLF).
22
+
23
+ We provide **validated Interslavic sentences** and host **parallel translations** from the community. We do **not** ship training code; others build their own repos and train on this data. At most, this repo has small **scripts** for validation, format checks, and conversion.
24
+
25
+ **Goal:** Quality governance — so that models marketed as "Interslavic" meet a clear standard and uncertified ones are clearly distinguished.
26
+
27
+ ---
28
+
29
+ ## Contents
30
+
31
+ | Path | Description |
32
+ |------|-------------|
33
+ | `monolingual/isv_sentences.parquet` | Single source of truth: Interslavic sentence id, text, and source. All rows verified before merge. |
34
+ | `parallel/*.parquet` | One Parquet per language pair (e.g. `isv-eng.parquet`). Each row references an `id` from the monolingual set. |
35
+ | `scripts/` | Format validation and optional conversion tools. |
36
+
37
+ **Format:** Parquet only (columnar, compact, streamable).
38
+
39
+ ---
40
+
41
+ ## Data formats
42
+
43
+ - **Monolingual** (`monolingual/isv_sentences.parquet`): columns `id`, `sentence`, `source`. License per source is documented (e.g. in CONTRIBUTING or SOURCES.md).
44
+ - **Parallel** (`parallel/isv-{lang}.parquet`): columns `id`, `isv`, `target`, `translator`, `method` (`human` / `machine_raw` / `machine_postedited`), `review_status`. Every `id` must exist in the monolingual set; `isv` must match exactly.
45
+
46
+ ---
47
+
48
+ ## Licensing
49
+
50
+ - **Data:** [ISLF Open Data License v1.0](LICENSE.md) — open use with **mandatory certification requirement** for models. If you train a model on this data, you must either get ISLF certification OR display a prominent disclaimer. This is a license condition, not optional.
51
+ - **Scripts/tooling:** [MIT License](scripts/LICENSE.md).
52
+ - **Quick summary:** [DATA-USE-AGREEMENT.md](DATA-USE-AGREEMENT.md) explains your obligations in plain language.
53
+
54
+ ---
55
+
56
+ ## How to use
57
+
58
+ 1. Clone the repo and read [CONTRIBUTING.md](CONTRIBUTING.md) for format and PR rules.
59
+ 2. Use the Parquet files in your own training pipeline. Each parallel file references `id`s from `monolingual/isv_sentences.parquet`.
60
+ 3. If you publish a model that produces Interslavic output, comply with the [DATA-USE-AGREEMENT](DATA-USE-AGREEMENT.md) (attribution, certification or disclaimer).
61
+
62
+ ---
63
+
64
+ ## Validation
65
+
66
+ From the repo root:
67
+
68
+ ```bash
69
+ pip install -r requirements.txt
70
+ python scripts/validate_corpus.py
71
+ ```
72
+
73
+ Run this before committing changes to `monolingual/` or `parallel/`.
74
+
75
+ ---
76
+
77
+ ## Certification (ISLF)
78
+
79
+ ISLF certifies **output quality** of models (like a language exam), not the software.
80
+
81
+ - **Certified models** may use the "Certified by ISLF" mark
82
+ - **Uncertified models** MUST display a mandatory disclaimer (see LICENSE.md §3.3)
83
+ - **Violations** result in license termination and public identification
84
+
85
+ A public registry of certified models will be maintained. Certification criteria will be published separately. Contact ISLF to begin the certification process.
SOURCES.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Data sources and licenses
2
+
3
+ Each `source` value in `monolingual/isv_sentences.parquet` maps to one of the entries below. When using sentences from a given source, you must comply with that source’s license.
4
+
5
+ | Source | Description | License |
6
+ |-----------|-----------------------------------------------|-----------------------------|
7
+ | `nnnbo` | “Nehaj Nesut Nas Běle Oblåky” © Aleksy Bernat | ISLF Open Data License v1.0 |
8
+
9
+ New sources will be added here as the corpus grows. Contributors must have rights to contribute under the stated license for each source they add.
monolingual/isv_sentences.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7d4368e25d7002d5ec70eed6d1018e376bab6c4f8743a1eb3f8d1592ae0b39a
3
+ size 2929
parallel/.gitkeep ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ pyarrow>=14.0.0
2
+ pandas>=2.0.0
scripts/LICENSE.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # License for scripts and tooling (code)
2
+
3
+ All scripts and tooling in this repository (e.g. in `scripts/` and `.github/`) are licensed under the MIT License. This applies only to code in this repo, not to other people’s training code or to the data (see LICENSE.md for the corpus).
4
+
5
+ ---
6
+
7
+ MIT License
8
+
9
+ Copyright (c) InterSlavic Linguistic Forum Foundation (ISLF)
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
scripts/validate_corpus.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Validate Interslavic MT corpus format.
4
+ - Monolingual: id, sentence, source; no duplicate ids.
5
+ - Parallel: id, isv, target, translator, method, review_status; ids exist in monolingual; isv matches.
6
+ Exits 0 on success, 1 on validation failure.
7
+ """
8
+ from pathlib import Path
9
+ import os
10
+ import sys
11
+
12
+ try:
13
+ import pandas as pd
14
+ except ImportError:
15
+ print("Requires pandas and pyarrow. Install with: pip install -r requirements.txt", file=sys.stderr)
16
+ sys.exit(2)
17
+
18
+ REPO_ROOT = Path(__file__).resolve().parent.parent
19
+ MONOLINGUAL_PATH = REPO_ROOT / "monolingual" / "isv_sentences.parquet"
20
+ PARALLEL_DIR = REPO_ROOT / "parallel"
21
+
22
+ MONO_COLUMNS = {"id", "sentence", "source"}
23
+ PARALLEL_COLUMNS = {"id", "isv", "target", "translator", "method", "review_status"}
24
+ METHOD_VALUES = {"human", "machine_raw", "machine_postedited"}
25
+
26
+
27
+ def main() -> None:
28
+ errors: list[str] = []
29
+ ci_mode = os.environ.get("GITHUB_ACTIONS", "").lower() in ("true", "1")
30
+
31
+ # --- Monolingual (single read) ---
32
+ df_mono = None
33
+ mono_ids: set[str] = set()
34
+ mono_id_to_sentence: dict[str, str] = {}
35
+
36
+ if not MONOLINGUAL_PATH.exists():
37
+ errors.append(f"Missing monolingual file: {MONOLINGUAL_PATH}")
38
+ else:
39
+ df_mono = pd.read_parquet(MONOLINGUAL_PATH)
40
+ cols = set(df_mono.columns)
41
+ if cols != MONO_COLUMNS:
42
+ missing = MONO_COLUMNS - cols
43
+ extra = cols - MONO_COLUMNS
44
+ if missing:
45
+ errors.append(f"monolingual: missing columns: {missing}")
46
+ if extra:
47
+ errors.append(f"monolingual: unexpected columns: {extra}")
48
+ if df_mono["id"].duplicated().any():
49
+ dupes = df_mono[df_mono["id"].duplicated(keep=False)]["id"].unique().tolist()
50
+ errors.append(f"monolingual: duplicate ids: {dupes}")
51
+ if df_mono["id"].isna().any() or df_mono["sentence"].isna().any() or df_mono["source"].isna().any():
52
+ errors.append("monolingual: null values in id, sentence, or source")
53
+ mono_ids = set(df_mono["id"].astype(str))
54
+ mono_id_to_sentence = dict(zip(df_mono["id"].astype(str), df_mono["sentence"].astype(str)))
55
+
56
+ # --- Parallel ---
57
+ for path in sorted(PARALLEL_DIR.glob("*.parquet")):
58
+ name = path.name
59
+ df = pd.read_parquet(path)
60
+ cols = set(df.columns)
61
+ if cols != PARALLEL_COLUMNS:
62
+ missing = PARALLEL_COLUMNS - cols
63
+ extra = cols - PARALLEL_COLUMNS
64
+ if missing:
65
+ errors.append(f"{name}: missing columns: {missing}")
66
+ if extra:
67
+ errors.append(f"{name}: unexpected columns: {extra}")
68
+ if "id" in df.columns and "isv" in df.columns and mono_id_to_sentence:
69
+ missing_ids = set(df["id"].astype(str)) - mono_ids
70
+ if missing_ids:
71
+ errors.append(f"{name}: ids not in monolingual: {list(missing_ids)[:10]}{'...' if len(missing_ids) > 10 else ''}")
72
+ # Vectorized isv match check (only for ids that exist in monolingual)
73
+ df_ids = df["id"].astype(str)
74
+ df_isv = df["isv"].astype(str).str.strip()
75
+ expected = df_ids.map(mono_id_to_sentence.get)
76
+ in_mono = df_ids.isin(mono_ids)
77
+ mismatch = in_mono & (df_isv != expected.str.strip())
78
+ if mismatch.any():
79
+ bad_ids = df.loc[mismatch, "id"].astype(str).tolist()
80
+ if ci_mode:
81
+ errors.append(f"{name}: id {bad_ids[0]} has isv text that does not match monolingual sentence")
82
+ else:
83
+ for rid in bad_ids:
84
+ errors.append(f"{name}: id {rid} has isv text that does not match monolingual sentence")
85
+ if "method" in df.columns and not set(df["method"].dropna().unique()).issubset(METHOD_VALUES):
86
+ bad = set(df["method"].dropna().unique()) - METHOD_VALUES
87
+ errors.append(f"{name}: invalid method values: {bad}")
88
+
89
+ if errors:
90
+ for e in errors:
91
+ print(e, file=sys.stderr)
92
+ sys.exit(1)
93
+ print("Validation passed.")
94
+
95
+
96
+ if __name__ == "__main__":
97
+ main()