|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import datasets |
|
import os |
|
|
|
class Childes(datasets.GeneratorBasedBuilder): |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name="childes_data", |
|
version=datasets.Version("1.0.0", ""), |
|
description="Childes language modeling dataset", |
|
) |
|
] |
|
|
|
|
|
|
|
def _info(self): |
|
|
|
citation_text = """\\ |
|
@article{sanchez2019childes, |
|
title={childes-db: A flexible and reproducible interface to the child language data exchange system}, |
|
author={Sanchez, Alessandro and Meylan, Stephan C and Braginsky, Mika and MacDonald, Kyle E and Yurovsky, Daniel and Frank, Michael C}, |
|
journal={Behavior research methods}, |
|
volume={51}, |
|
number={4}, |
|
pages={1928--1941}, |
|
year={2019}, |
|
publisher={Springer}} |
|
""" |
|
|
|
|
|
return datasets.DatasetInfo( |
|
description = "CHILDES data for language modeling", |
|
citation = citation_text, |
|
|
|
features=datasets.Features( |
|
{ |
|
"text": datasets.Value("string"), |
|
} |
|
), |
|
|
|
|
|
homepage="https://childes-db.stanford.edu/", |
|
) |
|
|
|
|
|
def _split_generators(self, download_helper): |
|
|
|
paths = download_helper.download_and_extract({ |
|
'train' : 'https://www.dropbox.com/s/dl/i282barrzlari08/train.txt?dl=1', |
|
'val' : 'https://www.dropbox.com/s/gx0rngo3v5mvlcf/validation.txt?dl=1', |
|
}) |
|
|
|
list_datasets = [] |
|
|
|
phases = ['train', 'val'] |
|
dataset_names = [ |
|
datasets.Split.TRAIN, |
|
datasets.Split.VALIDATION, |
|
] |
|
|
|
for phase, phase_name in zip(phases, dataset_names): |
|
|
|
this_dataset = datasets.SplitGenerator( |
|
name=phase_name, gen_kwargs={"file_path": paths[phase]} |
|
) |
|
|
|
list_datasets.append(this_dataset) |
|
|
|
|
|
return list_datasets |
|
|
|
def _generate_examples(self, file_path): |
|
|
|
|
|
with open(file_path, 'r', encoding="utf-8") as f: |
|
for idx, line in enumerate(f.readlines()): |
|
yield idx, {"text" : line} |
|
|
|
|
|
|