|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Inglish: An Indonesian English Translation Dataset.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
_DESCRIPTION = """\ |
|
This dataset is built as a playground for beginner to make a translation model for Indonesian and English. |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/jakartaresearch" |
|
|
|
|
|
|
|
|
|
_TRAIN_URL = "https://media.githubusercontent.com/media/jakartaresearch/hf-datasets/main/inglish/train.csv" |
|
_VAL_URL = "https://media.githubusercontent.com/media/jakartaresearch/hf-datasets/main/inglish/validation.csv" |
|
|
|
|
|
|
|
class Inglish(datasets.GeneratorBasedBuilder): |
|
"""Inglish: An Indonesian English Translation Dataset.""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
|
|
features = datasets.Features( |
|
{ |
|
"english": datasets.Value("string"), |
|
"indonesian": datasets.Value("string") |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
train_path = dl_manager.download_and_extract(_TRAIN_URL) |
|
val_path = dl_manager.download_and_extract(_VAL_URL) |
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}), |
|
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path}) |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath): |
|
"""Generate examples.""" |
|
with open(filepath, encoding="utf-8") as csv_file: |
|
csv_reader = csv.reader(csv_file, delimiter=",") |
|
next(csv_reader) |
|
for id_, row in enumerate(csv_reader): |
|
english, indo = row |
|
yield id_, {"english": english, "indonesian": indo} |