Datasets:

Multilinguality:
multilingual
Size Categories:
100M<n<1B
Language Creators:
found
Annotations Creators:
found
Source Datasets:
original
ArXiv:
License:
ccmatrix / test_ccmatrix.py
Yeb Havinga
Generate configs for all language pairs. Remove lang1 and lang2 as parameters.
9d7e2b0
from datasets import load_dataset
def test_streaming_dataset():
dataset = load_dataset("./ccmatrix.py", "nl-en", streaming=True)
assert list(dataset.keys()) == ["train"]
train_ds = dataset["train"]
i = iter(train_ds)
e = next(i)
assert e == {
"id": 0,
"score": 1.2499677,
"translation": {
"nl": "Zij kwamen uit alle delen van Egypte, evenals zij op de dag van Zijn komst zullen doen.",
"en": "They come from all parts of Egypt, just like they will at the day of His coming.",
},
}
e = next(i)
assert list(e.keys()) == ["id", "score", "translation"]
assert e == {
"id": 1,
"score": 1.2498379,
"translation": {
"nl": "En we moeten elke waarheid vals noemen die niet minstens door een lach vergezeld ging.”",
"en": 'And we should call every truth false which was not accompanied by at least one laugh."',
},
}
def test_streaming_dataset_2():
dataset = load_dataset("./ccmatrix.py", "nl-en", streaming=True)
assert list(dataset.keys()) == ["train"]
train_ds = dataset["train"]
i = iter(train_ds)
e = next(i)
assert e == {
"id": 0,
"score": 1.2499677,
"translation": {
"nl": "Zij kwamen uit alle delen van Egypte, evenals zij op de dag van Zijn komst zullen doen.",
"en": "They come from all parts of Egypt, just like they will at the day of His coming.",
},
}
e = next(i)
assert list(e.keys()) == ["id", "score", "translation"]
assert e == {
"id": 1,
"score": 1.2498379,
"translation": {
"nl": "En we moeten elke waarheid vals noemen die niet minstens door een lach vergezeld ging.”",
"en": 'And we should call every truth false which was not accompanied by at least one laugh."',
},
}
def test_max_train_samples_1():
dataset = load_dataset("./ccmatrix.py", "nl-en", max_train_samples=123)
assert list(dataset.keys()) == ["train"]
train_ds = dataset["train"]
assert len(train_ds) == 123
i = iter(train_ds)
e = next(i)
assert e == {
"id": 0,
"score": 1.2499676942825317,
"translation": {
"nl": "Zij kwamen uit alle delen van Egypte, evenals zij op de dag van Zijn komst zullen doen.",
"en": "They come from all parts of Egypt, just like they will at the day of His coming.",
},
}
e = next(i)
assert list(e.keys()) == ["id", "score", "translation"]
assert e == {
"id": 1,
"score": 1.249837875366211,
"translation": {
"nl": "En we moeten elke waarheid vals noemen die niet minstens door een lach vergezeld ging.”",
"en": 'And we should call every truth false which was not accompanied by at least one laugh."',
},
}
def test_max_train_samples_2():
dataset = load_dataset("./ccmatrix.py", "nl-en", max_train_samples=256)
assert list(dataset.keys()) == ["train"]
train_ds = dataset["train"]
assert len(train_ds) == 256
i = iter(train_ds)
e = next(i)