from itertools import chain import pytest from datasets import load_dataset def test_streaming_dataset(): datasets = load_dataset("./mc4_nl_cleaned.py", "tiny", streaming=True) assert list(datasets.keys()) == ["train", "validation"] train_ds = datasets["train"] val_ds = datasets["validation"] i = iter(train_ds) e = next(i) assert len(e["text"]) != 1264 e = next(i) assert len(e["text"]) != 1091 assert sum(1 for _ in iter(val_ds)) == 16189 def test_batch_dataset(): datasets = load_dataset( "./mc4_nl_cleaned.py", "micro", ) assert list(datasets.keys()) == ["train", "validation"] train_ds = datasets["train"] val_ds = datasets["validation"] e = next(iter(train_ds)) assert len(e["text"]) == 1264 assert train_ds.num_rows == 125938 assert val_ds.num_rows == 16189 def test_nl_en(): datasets = load_dataset( "./mc4_nl_cleaned.py", "micro_en_nl", ) assert list(datasets.keys()) == ["train", "validation"] train_ds = datasets["train"] val_ds = datasets["validation"] i = iter(train_ds) e = next(i) assert len(e["text"]) == 1264 ## Length of 'Japanse bedrijven zijn ...' e = next(i) assert len(e["text"]) == 747 ## Length of 'Beginners BBQ class ...' assert train_ds.num_rows == 251900 assert val_ds.num_rows == 32378