Datasets:
ArXiv:
License:
File size: 3,171 Bytes
03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db 9d7e2b0 03ab1db |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
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)
|