IndicXParaphrase / IndicXParaphrase.py
sumanthd's picture
add gu data
f302676
raw
history blame
2.2 kB
"""TODO(Indicxparaphrase): Add a description here."""
import json
import pandas as pd
import datasets
_HOMEPAGE = ""
_CITATION = """\
"""
_DESCRIPTION = """\
"""
_LANG = ["as", "bn", "gu", "hi", "kn", "ml", "mr", "or", "pa", "te"]
_URL = "https://huggingface.co./datasets/ai4bharat/IndicXParaphrase/resolve/main/data/{language}.tsv"
_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"),
"sentence1": datasets.Value("string"),
"sentence2": datasets.Value("string"),
"label": datasets.features.ClassLabel(names=["0", "1"]),
}
),
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) 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")
for idx, row in df.iterrows():
yield idx, {
"english": row['en'],
"sentence1": row['sentence1'],
"sentence2": row['sentence2'],
"label": row['label'],
}