|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""NLP4SGPAPERS dataset: a scientific dataset with three associated tasks that can help identify NLP4SG papers""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """ |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
NLP4SGPAPERS dataset: a scientific dataset with three associated tasks that can help identify NLP4SG papers |
|
""" |
|
|
|
|
|
_HOMEPAGE = "" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"train": "https://huggingface.co./datasets/feradauto/NLP4SGPapers/resolve/main/data/train.json", |
|
"test": "https://huggingface.co./datasets/feradauto/NLP4SGPapers/resolve/main/data/test.json", |
|
"validation": "https://huggingface.co./datasets/feradauto/NLP4SGPapers/resolve/main/data/validation.json", |
|
} |
|
|
|
class NLP4SGPapers(datasets.GeneratorBasedBuilder): |
|
"""A scientific dataset with three associated tasks that can help identify NLP4SG papers""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="data", version=VERSION, description="data")] |
|
|
|
DEFAULT_CONFIG_NAME = "data" |
|
|
|
def _info(self): |
|
|
|
features = datasets.Features( |
|
{ |
|
"ID": datasets.Value("string"), |
|
"url": datasets.Value("string"), |
|
"title": datasets.Value("string"), |
|
"abstract": datasets.Value("string"), |
|
"label_nlp4sg": datasets.Value("bool"), |
|
"task": datasets.Sequence(feature=datasets.Value("string")), |
|
"method": datasets.Sequence(feature=datasets.Value("string")), |
|
"goal1": datasets.Value("string"), |
|
"goal2": datasets.Value("string"), |
|
"goal3": datasets.Value("string"), |
|
"acknowledgments": datasets.Value("string"), |
|
"year": datasets.Value("string"), |
|
"sdg1": datasets.Value("bool"), |
|
"sdg2": datasets.Value("bool"), |
|
"sdg3": datasets.Value("bool"), |
|
"sdg4": datasets.Value("bool"), |
|
"sdg5": datasets.Value("bool"), |
|
"sdg6": datasets.Value("bool"), |
|
"sdg7": datasets.Value("bool"), |
|
"sdg8": datasets.Value("bool"), |
|
"sdg9": datasets.Value("bool"), |
|
"sdg10": datasets.Value("bool"), |
|
"sdg11": datasets.Value("bool"), |
|
"sdg12": datasets.Value("bool"), |
|
"sdg13": datasets.Value("bool"), |
|
"sdg14": datasets.Value("bool"), |
|
"sdg15": datasets.Value("bool"), |
|
"sdg16": datasets.Value("bool"), |
|
"sdg17": datasets.Value("bool"), |
|
|
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
downloaded_files = dl_manager.download_and_extract(_URLS) |
|
|
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}), |
|
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["validation"]}), |
|
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}), |
|
] |
|
|
|
|
|
|
|
def _generate_examples(self, filepath): |
|
|
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
for key, row in enumerate(f): |
|
data = json.loads(row) |
|
yield key, { |
|
"ID": data["ID"], |
|
"url": data["url"], |
|
"title": data["title"], |
|
"abstract": data["abstract"], |
|
"label_nlp4sg": data["label_nlp4sg"], |
|
"task": data["task"], |
|
"method": data["method"], |
|
"goal1": data["goal1"], |
|
"goal2": data["goal2"], |
|
"goal3": data["goal3"], |
|
"acknowledgments": data["acknowledgments"], |
|
"year": data["year"], |
|
"sdg1": data["sdg1"], |
|
"sdg2": data["sdg2"], |
|
"sdg3": data["sdg3"], |
|
"sdg4": data["sdg4"], |
|
"sdg5": data["sdg5"], |
|
"sdg6": data["sdg6"], |
|
"sdg7": data["sdg7"], |
|
"sdg8": data["sdg8"], |
|
"sdg9": data["sdg9"], |
|
"sdg10": data["sdg10"], |
|
"sdg11": data["sdg11"], |
|
"sdg12": data["sdg12"], |
|
"sdg13": data["sdg13"], |
|
"sdg14": data["sdg14"], |
|
"sdg15": data["sdg15"], |
|
"sdg16": data["sdg16"], |
|
"sdg17": data["sdg17"], |
|
} |
|
|