from datasets import load_dataset def test_streaming_dataset(): datasets = load_dataset("./ccmatrix.py", lang1="nl", lang2="en", streaming=True) assert list(datasets.keys()) == ["train"] train_ds = datasets["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(): datasets = load_dataset("./ccmatrix.py", "nl-en", streaming=True) assert list(datasets.keys()) == ["train"] train_ds = datasets["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_small_config(): datasets = load_dataset("./ccmatrix.py", "nl-en-1000_000") assert list(datasets.keys()) == ["train"] train_ds = datasets["train"] assert len(train_ds) == 1000000 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_medium_config(): datasets = load_dataset("./ccmatrix.py", "nl-en-25_000_000", streaming=True) assert list(datasets.keys()) == ["train"] train_ds = datasets["train"] i = iter(train_ds) e = next(i)