|
"""TODO(Indicxparaphrase): Add a description here.""" |
|
|
|
|
|
import json |
|
import pandas as pd |
|
import datasets |
|
|
|
|
|
_HOMEPAGE = "" |
|
|
|
_CITATION = """\ |
|
|
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
|
|
""" |
|
|
|
_LANG = ["as", "hi", "kn", "ml", "mr", "pa", "te"] |
|
_URL = "https://huggingface.co./datasets/ai4bharat/IndicXParaphrase/resolve/main/data/{split}.{language}.jsonl" |
|
_VERSION = datasets.Version("1.0.0", "First version of Indicxparaphrase") |
|
|
|
|
|
class Indicxparaphrase(datasets.GeneratorBasedBuilder): |
|
"""TODO(Indicxparaphrase): Short description of my dataset.""" |
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name=f"{lang}", |
|
description=f"Cross-lingual paraphrase dataset for language {lang}", |
|
version=_VERSION, |
|
) |
|
for lang in _LANG |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION + self.config.description, |
|
features=datasets.Features( |
|
{ |
|
"english": datasets.Value("string"), |
|
"translation": datasets.Value("string"), |
|
"paraphrase": datasets.Value("string"), |
|
"non-paraphrase": datasets.Value("string"), |
|
} |
|
), |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
language = self.config.name |
|
splits = {datasets.Split.TEST: "test"} |
|
data_urls = { |
|
split: _URL.format(language=language, split=splits[split]) for split in splits |
|
} |
|
dl_paths = dl_manager.download(data_urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=split, |
|
gen_kwargs={"filepath": dl_paths[split]}, |
|
) |
|
for split in splits |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
"""Yields examples.""" |
|
df = pd.read_csv(filepath, sep="\t", header=None) |
|
for idx, row in df.iterrows(): |
|
yield idx, { |
|
"english": row[0], |
|
"translation": row[1], |
|
"paraphrase": row[2], |
|
"non-paraphrase": row[3], |
|
} |