DiscEvalMT / discevalmt.py
rbawden's picture
Update discevalmt.py
f9fa9d8 verified
raw
history blame
No virus
2.29 kB
# coding=utf-8
'''DiscEvalMT: DiscEvalMT: Contrastive test sets for the evaluation of discourse in machine translation (v2)'''
import json
import datasets
logger = datasets.logging.get_logger(__name__)
_CITATION = '''\
@inproceedings{bawden-etal-2018-evaluating,
title = "Evaluating Discourse Phenomena in Neural Machine Translation",
author = "Bawden, Rachel and Sennrich, Rico and Birch, Alexandra and Haddow, Barry",
booktitle = {{Proceedings of the 2018 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers)}},
month = jun,
year = "2018",
address = "New Orleans, Louisiana",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/N18-1118",
doi = "10.18653/v1/N18-1118",
pages = "1304--1313"
}
'''
_DESCRIPTION = '''\
English-French hand-crafted contrastive test set to test anaphora and lexical choice
'''
_URLS = {
'test-lexical_choice': 'lexical_choice.json',
'test-anaphora': 'anaphora.json'
}
class DiscEvalMTConfig(datasets.BuilderConfig):
'''BuilderConfig for DiscEvalMT.'''
def __init__(self, evaltype: str, **kwargs):
"""BuilderConfig for DiscEvalMT.
Args:
**kwargs: keyword arguments forwarded to super.
"""
self.evaltype = evaltype
super().__init__(**kwargs)
class DiscEvalMT(datasets.GeneratorBasedBuilder):
'''DiscEvalMT: English-French contrastive test set for 2 discourse phenomena (anaphora and lexical cohesion)'''
BUILDER_CONFIG_CLASS = DiscEvalMTConfig
BUILDER_CONFIGS = [
DiscEvalMTConfig(
name='anaphora',
filename='test-anaphora',
version=datasets.Version('2.0.0', ''),
),
DiscEvalMTConfig(
name='lexical choice',
filename='test-lexical_choice',
version=datasets.Version('2.0.0', ''),
),
]
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(_URLS)
print(self.config.filename)
return datasets.SplitGenerator(name=split, gen_kwargs={'filepath': downloaded_files[self.config.filename]}),