Datasets:
mteb
/

Modalities:
Text
Formats:
json
ArXiv:
Libraries:
Datasets
Dask
License:
bucc-bitext-mining / bucc-bitext-mining.py
nouamanetazi's picture
nouamanetazi HF staff
Update bucc-bitext-mining.py
394dc20
raw
history blame
1.73 kB
# coding=utf-8
"""BUCC"""
import json
import datasets
import os
import gzip
logger = datasets.logging.get_logger(__name__)
_DESCRIPTION = """\
BUCC 2018 Shared Task test dataset
"""
_LANGUAGES = [
'de-en',
'fr-en',
'ru-en',
'zh-en'
]
class BUCC(datasets.GeneratorBasedBuilder):
"""BUCC Cross-lingual"""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name=name,
version=datasets.Version("1.0.0"),
description=f"BUCC cross-lingual dataset for {name} language pair.",
)
for name in _LANGUAGES
]
DEFAULT_CONFIG_NAME = 'fr-en'
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"sentence1": datasets.Sequence(datasets.Value("string")),
"sentence2": datasets.Sequence(datasets.Value("string")),
"gold": datasets.Sequence([datasets.Value("int32")])
},
),
supervised_keys=None,
homepage="https://comparable.limsi.fr/bucc2018/bucc2018-task.html",
)
def _split_generators(self, dl_manager):
url = f'{self.config.name}/test.json.gz'
archive_path = dl_manager.download(url)
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"text_path": archive_path,
},
),
]
def _generate_examples(self, text_path):
"""Yields examples."""
with gzip.open(text_path,'rt') as f:
for i, line in enumerate(f):
yield i, json.loads(line)