|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity Recognition""" |
|
|
|
import os |
|
|
|
import datasets |
|
|
|
|
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{derczynski-kjeldsen-2019-bornholmsk, |
|
title = "Bornholmsk Natural Language Processing: Resources and Tools", |
|
author = "Derczynski, Leon and |
|
Kjeldsen, Alex Speed", |
|
booktitle = "Proceedings of the 22nd Nordic Conference on Computational Linguistics", |
|
month = sep # "{--}" # oct, |
|
year = "2019", |
|
address = "Turku, Finland", |
|
publisher = {Link{\"o}ping University Electronic Press}, |
|
url = "https://aclanthology.org/W19-6138", |
|
pages = "338--344", |
|
abstract = {This paper introduces language processing resources and tools for Bornholmsk, a language spoken on the island of Bornholm, with roots in Danish and closely related to Scanian. This presents an overview of the language and available data, and the first NLP models for this living, minority Nordic language. Sammenfattnijng p{\aa} borrijnholmst: D{\ae}jnna artikkelijn introduserer naturspr{\aa}gsresurser {\aa} varktoi for borrijnholmst, ed spr{\aa}g a d{\ae}r snakkes p{\aa} {\"o}n Borrijnholm me r{\o}dder i danst {\aa} i n{\ae}r familia me sk{\aa}nst. Artikkelijn gjer ed {\^a}uersyn {\^a}uer spr{\aa}ged {\aa} di datan som fijnnes, {\aa} di fosste NLP mod{\ae}llarna for d{\ae}tta l{\ae}wenes nordiska minnret{\^a}lsspr{\aa}ged.}, |
|
} |
|
|
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
This corpus introduces language processing resources and tools for Bornholmsk, a language spoken on the island of Bornholm, with roots in Danish and closely related to Scanian. |
|
|
|
Sammenfattnijng på borrijnholmst: Dæjnna artikkelijn introduserer natursprågsresurser å varktoi for borrijnholmst, ed språg a dær snakkes på ön Borrijnholm me rødder i danst å i nær familia me skånst. |
|
""" |
|
|
|
_URL_BASE = "https://github.com/StrombergNLP/bornholmsk/blob/0bdb51bf7522c1d154bcc9c54f6ffd4c5125a121/parallel." |
|
|
|
|
|
class BornholmskConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for Bornholmsk""" |
|
|
|
def __init__(self, **kwargs): |
|
"""BuilderConfig Bornholmsk. |
|
|
|
Args: |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
super(BornholmskConfig, self).__init__(**kwargs) |
|
|
|
|
|
class Bornholmsk(datasets.GeneratorBasedBuilder): |
|
"""Bornholmsk dataset.""" |
|
|
|
BUILDER_CONFIGS = [ |
|
BornholmskConfig(name="Bornholmsk", version=datasets.Version("1.0.0"), description="Bornholmsk text"), |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"id": datasets.Value("string"), |
|
"da_bornholm": datasets.Value("string"), |
|
"da": datasets.Value("string"), |
|
} |
|
), |
|
supervised_keys=None, |
|
homepage="https://github.com/StrombergNLP/bornholmsk", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
downloaded_files = {} |
|
for lang in ('da', 'da-bornholm'): |
|
for partition in ('train', 'val', 'test'): |
|
part = f"{lang}.{partition}" |
|
downloaded_files[part] = dl_manager.download_and_extract(_URL_BASE + part) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={"filepath": |
|
{ |
|
'da': downloaded_files['da.train'], |
|
'da-bornholm':downloaded_files['da-bornholm.train'] |
|
} |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={"filepath": |
|
{ |
|
'da': downloaded_files['da.val'], |
|
'da-bornholm':downloaded_files['da-bornholm.val'] |
|
} |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={"filepath": |
|
{ |
|
'da': downloaded_files['da.test'], |
|
'da-bornholm':downloaded_files['da-bornholm.test'] |
|
} |
|
} |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
logger.info("⏳ Generating examples from = %s and %s", (filepath['da'], filepath['da-bornholm'])) |
|
guid = 0 |
|
with open(filepath['da-bornholm'], encoding="utf-8") as f_da: |
|
with open(filepath['da'], encoding="utf-8") as f_bo: |
|
bo = f_bo.readlines() |
|
da = f_da.readlines() |
|
for instance in zip(bo, da): |
|
yield guid, { |
|
"id": str(guid), |
|
"da_bornholm": instance[0], |
|
"da": instance[1], |
|
} |
|
guid += 1 |
|
|