Datasets:
Publish 5000 real globally deduplicated translation pairs with provenance and checksums
Browse files- README.md +68 -0
- build_dataset.py +119 -0
- data/test.parquet +3 -0
- data/train.parquet +3 -0
- data/validation.parquet +3 -0
- manifest.json +49 -0
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: AstheralDataset
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- de
|
| 6 |
+
- fr
|
| 7 |
+
- es
|
| 8 |
+
- it
|
| 9 |
+
- pt
|
| 10 |
+
task_categories:
|
| 11 |
+
- translation
|
| 12 |
+
size_categories:
|
| 13 |
+
- 1K<n<10K
|
| 14 |
+
license: other
|
| 15 |
+
license_name: source-corpus-terms
|
| 16 |
+
license_link: https://huggingface.co/datasets/Helsinki-NLP/opus-100
|
| 17 |
+
configs:
|
| 18 |
+
- config_name: default
|
| 19 |
+
data_files:
|
| 20 |
+
- split: train
|
| 21 |
+
path: data/train.parquet
|
| 22 |
+
- split: validation
|
| 23 |
+
path: data/validation.parquet
|
| 24 |
+
- split: test
|
| 25 |
+
path: data/test.parquet
|
| 26 |
+
---
|
| 27 |
+
# AstheralDataset
|
| 28 |
+
|
| 29 |
+
**5,000 real English translation pairs**, curated by SEE7 for German, French, Spanish, Italian and Portuguese.
|
| 30 |
+
|
| 31 |
+
## Contents
|
| 32 |
+
|
| 33 |
+
| Target | Train | Validation | Test | Total |
|
| 34 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 35 |
+
| German | 900 | 50 | 50 | 1,000 |
|
| 36 |
+
| French | 900 | 50 | 50 | 1,000 |
|
| 37 |
+
| Spanish | 900 | 50 | 50 | 1,000 |
|
| 38 |
+
| Italian | 900 | 50 | 50 | 1,000 |
|
| 39 |
+
| Portuguese | 900 | 50 | 50 | 1,000 |
|
| 40 |
+
| **Total** | **4,500** | **250** | **250** | **5,000** |
|
| 41 |
+
|
| 42 |
+
## Record fields
|
| 43 |
+
|
| 44 |
+
Each row contains a unique SHA-256 ID, English source text, translated target text, source and target language codes, a translation instruction, and the original dataset/config/split/revision/row index.
|
| 45 |
+
|
| 46 |
+
## Curation
|
| 47 |
+
|
| 48 |
+
Text is drawn from real parallel sentences in [OPUS-100](https://huggingface.co/datasets/Helsinki-NLP/opus-100). Selection preserves the original train, validation and test split membership. All 10,000 text values are globally unique after Unicode normalization, case folding, punctuation removal and whitespace normalization. Source-target identity, short fragments, markup and placeholder patterns are filtered. No model-generated translations are included.
|
| 49 |
+
|
| 50 |
+
The complete build script, exact source revision, split counts, rejection counts and Parquet checksums are published alongside the data.
|
| 51 |
+
|
| 52 |
+
## Load
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from datasets import load_dataset
|
| 56 |
+
|
| 57 |
+
dataset = load_dataset("SEE7/AstheralDataset")
|
| 58 |
+
example = dataset["train"][0]
|
| 59 |
+
print(example["source_text"])
|
| 60 |
+
print(example["target_text"])
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Provenance and attribution
|
| 64 |
+
|
| 65 |
+
Source: Helsinki-NLP/opus-100, revision 805090dc28bf78897da9641cdf08b61287580df9.
|
| 66 |
+
OPUS-100: Zhang et al. (2020), “Improving Massively Multilingual Neural Machine Translation and Zero-Shot Translation.” Original parallel text comes from the OPUS collection. The original source corpus terms remain applicable.
|
| 67 |
+
|
| 68 |
+
Curated dataset repository: SEE7/AstheralDataset.
|
build_dataset.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json,hashlib,re,unicodedata,collections,time
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from datasets import load_dataset,Dataset
|
| 4 |
+
from huggingface_hub import HfApi
|
| 5 |
+
api=HfApi();source='Helsinki-NLP/opus-100';revision=api.dataset_info(source).sha
|
| 6 |
+
out=Path('/tmp/AstheralDataset');(out/'data').mkdir(parents=True,exist_ok=True)
|
| 7 |
+
langs={'de':'German','fr':'French','es':'Spanish','it':'Italian','pt':'Portuguese'}
|
| 8 |
+
seen_values=set();ids=set();splits={'train':[],'validation':[],'test':[]};rejected=collections.Counter()
|
| 9 |
+
def normalize(s):
|
| 10 |
+
s=unicodedata.normalize('NFKC',s).casefold()
|
| 11 |
+
return ' '.join(''.join(c if c.isalnum() else ' ' for c in s).split())
|
| 12 |
+
for split,n in [('test',50),('validation',50),('train',900)]:
|
| 13 |
+
for lang,name in langs.items():
|
| 14 |
+
config='-'.join(sorted(['en',lang]));ds=load_dataset(source,config,split=split,revision=revision).shuffle(seed=20261113)
|
| 15 |
+
added=0
|
| 16 |
+
for index,row in enumerate(ds):
|
| 17 |
+
a=row['translation']['en'].strip();b=row['translation'][lang].strip()
|
| 18 |
+
if not(20<=len(a)<=500 and 12<=len(b)<=600) or len(a.split())<4 or len(b.split())<3:
|
| 19 |
+
rejected['length']+=1;continue
|
| 20 |
+
if any(re.search(r'lorem ipsum|placeholder|\bTODO\b|https?://|<[^>]+>|\{\{|\ufffd',s,re.I) for s in [a,b]):
|
| 21 |
+
rejected['non_sentence_content']+=1;continue
|
| 22 |
+
x,y=normalize(a),normalize(b)
|
| 23 |
+
if x==y or x in seen_values or y in seen_values:
|
| 24 |
+
rejected['duplicate_or_identical_text']+=1;continue
|
| 25 |
+
uid=hashlib.sha256((lang+'\\0'+x+'\\0'+y).encode()).hexdigest()
|
| 26 |
+
assert uid not in ids
|
| 27 |
+
ids.add(uid);seen_values.update([x,y])
|
| 28 |
+
record={'id':uid,'source_language':'en','target_language':lang,'source_text':a,'target_text':b,'instruction':'Translate from English to '+name+'. Return only the translation.','source_dataset':source,'source_config':config,'source_split':split,'source_revision':revision,'source_row_index':int(ds._indices.column(0)[index].as_py()) if ds._indices is not None else index}
|
| 29 |
+
splits[split].append(record);added+=1
|
| 30 |
+
if added==n:break
|
| 31 |
+
assert added==n,(lang,split,added)
|
| 32 |
+
print('COLLECTED',split,lang,added,flush=True)
|
| 33 |
+
for split,rows in splits.items():
|
| 34 |
+
Dataset.from_list(rows).shuffle(seed=42).to_parquet(str(out/'data'/f'{split}.parquet'))
|
| 35 |
+
total=sum(map(len,splits.values()));assert total==5000 and len(ids)==5000 and len(seen_values)==10000
|
| 36 |
+
counter={split:dict(collections.Counter(r['target_language'] for r in rows)) for split,rows in splits.items()}
|
| 37 |
+
manifest={'name':'AstheralDataset','version':'1.0','total_examples':total,'unique_example_ids':len(ids),'unique_normalized_text_values':len(seen_values),'split_counts':{k:len(v) for k,v in splits.items()},'language_counts':counter,'source_dataset':source,'source_revision':revision,'normalization':'Unicode NFKC, casefold, punctuation removed, whitespace collapsed','deduplication':'Global source/target text uniqueness across all languages and splits; identical source-target pairs excluded','rejected':dict(rejected),'file_sha256':{p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in (out/'data').glob('*.parquet')}}
|
| 38 |
+
(out/'manifest.json').write_text(json.dumps(manifest,indent=2))
|
| 39 |
+
(out/'build_dataset.py').write_text(Path(__file__).read_text())
|
| 40 |
+
readme='''---
|
| 41 |
+
pretty_name: AstheralDataset
|
| 42 |
+
language:
|
| 43 |
+
- en
|
| 44 |
+
- de
|
| 45 |
+
- fr
|
| 46 |
+
- es
|
| 47 |
+
- it
|
| 48 |
+
- pt
|
| 49 |
+
task_categories:
|
| 50 |
+
- translation
|
| 51 |
+
size_categories:
|
| 52 |
+
- 1K<n<10K
|
| 53 |
+
license: other
|
| 54 |
+
license_name: source-corpus-terms
|
| 55 |
+
license_link: https://huggingface.co/datasets/Helsinki-NLP/opus-100
|
| 56 |
+
configs:
|
| 57 |
+
- config_name: default
|
| 58 |
+
data_files:
|
| 59 |
+
- split: train
|
| 60 |
+
path: data/train.parquet
|
| 61 |
+
- split: validation
|
| 62 |
+
path: data/validation.parquet
|
| 63 |
+
- split: test
|
| 64 |
+
path: data/test.parquet
|
| 65 |
+
---
|
| 66 |
+
# AstheralDataset
|
| 67 |
+
|
| 68 |
+
**5,000 real English translation pairs**, curated by SEE7 for German, French, Spanish, Italian and Portuguese.
|
| 69 |
+
|
| 70 |
+
## Contents
|
| 71 |
+
|
| 72 |
+
| Target | Train | Validation | Test | Total |
|
| 73 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 74 |
+
| German | 900 | 50 | 50 | 1,000 |
|
| 75 |
+
| French | 900 | 50 | 50 | 1,000 |
|
| 76 |
+
| Spanish | 900 | 50 | 50 | 1,000 |
|
| 77 |
+
| Italian | 900 | 50 | 50 | 1,000 |
|
| 78 |
+
| Portuguese | 900 | 50 | 50 | 1,000 |
|
| 79 |
+
| **Total** | **4,500** | **250** | **250** | **5,000** |
|
| 80 |
+
|
| 81 |
+
## Record fields
|
| 82 |
+
|
| 83 |
+
Each row contains a unique SHA-256 ID, English source text, translated target text, source and target language codes, a translation instruction, and the original dataset/config/split/revision/row index.
|
| 84 |
+
|
| 85 |
+
## Curation
|
| 86 |
+
|
| 87 |
+
Text is drawn from real parallel sentences in [OPUS-100](https://huggingface.co/datasets/Helsinki-NLP/opus-100). Selection preserves the original train, validation and test split membership. All 10,000 text values are globally unique after Unicode normalization, case folding, punctuation removal and whitespace normalization. Source-target identity, short fragments, markup and placeholder patterns are filtered. No model-generated translations are included.
|
| 88 |
+
|
| 89 |
+
The complete build script, exact source revision, split counts, rejection counts and Parquet checksums are published alongside the data.
|
| 90 |
+
|
| 91 |
+
## Load
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
from datasets import load_dataset
|
| 95 |
+
|
| 96 |
+
dataset = load_dataset("SEE7/AstheralDataset")
|
| 97 |
+
example = dataset["train"][0]
|
| 98 |
+
print(example["source_text"])
|
| 99 |
+
print(example["target_text"])
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
## Provenance and attribution
|
| 103 |
+
|
| 104 |
+
Source: Helsinki-NLP/opus-100, revision '''+revision+'''.
|
| 105 |
+
OPUS-100: Zhang et al. (2020), “Improving Massively Multilingual Neural Machine Translation and Zero-Shot Translation.” Original parallel text comes from the OPUS collection. The original source corpus terms remain applicable.
|
| 106 |
+
|
| 107 |
+
Curated dataset repository: SEE7/AstheralDataset.
|
| 108 |
+
'''
|
| 109 |
+
(out/'README.md').write_text(readme)
|
| 110 |
+
api.upload_folder(repo_id='SEE7/AstheralDataset',repo_type='dataset',folder_path=str(out),commit_message='Publish 5000 real globally deduplicated translation pairs with provenance and checksums')
|
| 111 |
+
# Download the published splits through the public dataset interface and validate the real release.
|
| 112 |
+
published=load_dataset('SEE7/AstheralDataset')
|
| 113 |
+
assert {k:len(v) for k,v in published.items()}=={'train':4500,'validation':250,'test':250}
|
| 114 |
+
values=[];row_ids=[]
|
| 115 |
+
for split in published:
|
| 116 |
+
for row in published[split]:
|
| 117 |
+
values.extend([normalize(row['source_text']),normalize(row['target_text'])]);row_ids.append(row['id'])
|
| 118 |
+
assert len(set(values))==10000 and len(set(row_ids))==5000
|
| 119 |
+
print('PUBLISHED_VERIFIED',json.dumps(manifest),flush=True)
|
data/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef098abdabd64007cb91451f25e9d452f076b897bc11ce464fc9157b7b8fffa3
|
| 3 |
+
size 60081
|
data/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db2ccfff2cb499647cd134bdbf03840b9d72c98ccbadf5af25572a189cb2bcc5
|
| 3 |
+
size 938671
|
data/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e65a4bc923eadaafa3cf92b8af54aeadb1aafdd2265547c52be078f6131db55
|
| 3 |
+
size 60972
|
manifest.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "AstheralDataset",
|
| 3 |
+
"version": "1.0",
|
| 4 |
+
"total_examples": 5000,
|
| 5 |
+
"unique_example_ids": 5000,
|
| 6 |
+
"unique_normalized_text_values": 10000,
|
| 7 |
+
"split_counts": {
|
| 8 |
+
"train": 4500,
|
| 9 |
+
"validation": 250,
|
| 10 |
+
"test": 250
|
| 11 |
+
},
|
| 12 |
+
"language_counts": {
|
| 13 |
+
"train": {
|
| 14 |
+
"de": 900,
|
| 15 |
+
"fr": 900,
|
| 16 |
+
"es": 900,
|
| 17 |
+
"it": 900,
|
| 18 |
+
"pt": 900
|
| 19 |
+
},
|
| 20 |
+
"validation": {
|
| 21 |
+
"de": 50,
|
| 22 |
+
"fr": 50,
|
| 23 |
+
"es": 50,
|
| 24 |
+
"it": 50,
|
| 25 |
+
"pt": 50
|
| 26 |
+
},
|
| 27 |
+
"test": {
|
| 28 |
+
"de": 50,
|
| 29 |
+
"fr": 50,
|
| 30 |
+
"es": 50,
|
| 31 |
+
"it": 50,
|
| 32 |
+
"pt": 50
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
"source_dataset": "Helsinki-NLP/opus-100",
|
| 36 |
+
"source_revision": "805090dc28bf78897da9641cdf08b61287580df9",
|
| 37 |
+
"normalization": "Unicode NFKC, casefold, punctuation removed, whitespace collapsed",
|
| 38 |
+
"deduplication": "Global source/target text uniqueness across all languages and splits; identical source-target pairs excluded",
|
| 39 |
+
"rejected": {
|
| 40 |
+
"duplicate_or_identical_text": 66,
|
| 41 |
+
"length": 1939,
|
| 42 |
+
"non_sentence_content": 42
|
| 43 |
+
},
|
| 44 |
+
"file_sha256": {
|
| 45 |
+
"train.parquet": "db2ccfff2cb499647cd134bdbf03840b9d72c98ccbadf5af25572a189cb2bcc5",
|
| 46 |
+
"validation.parquet": "7e65a4bc923eadaafa3cf92b8af54aeadb1aafdd2265547c52be078f6131db55",
|
| 47 |
+
"test.parquet": "ef098abdabd64007cb91451f25e9d452f076b897bc11ce464fc9157b7b8fffa3"
|
| 48 |
+
}
|
| 49 |
+
}
|