Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
json
Sub-tasks:
multi-class-classification
Size:
1K - 10K
File size: 5,604 Bytes
d2c5b2b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
from typing import List
from datasets.tasks import QuestionAnsweringExtractive, LanguageModeling, MaskedLM, MultipleChoice, TextClassification, TextToTextGeneration
import pandas as pd
import datasets
import os
logger = datasets.logging.get_logger(__name__)
CITATION = """TBA"""
_DESCRIPTION = """\
ISCO ESCO Occupations Taxonomy Dataset (IEOTD) is a hierarhical \
taxonomy dataset, consisting of occupation groups from ISCO, \
occupations from ESCO and definitions.
"""
# TODO: Update license based on ILO and ESCO
LICENSE = """\
By accessing ISCO ESCO Occupations Taxonomy Dataset, you indicate that you agree to the terms and conditions associated with their use. Please read the IEA Disclaimer and License Agreement for full details. [Disclaimer_and_License_Agreement.pdf (iea.nl)](https://www.iea.nl/sites/default/files/data-repository/Disclaimer_and_License_Agreement.pdf)
"""
HOMEPAGE_URL = "https://iea.nl"
_URL = "/"
_URLS = {
"full": _URL + "data/data.parquet",
}
class IscoEscoTaxonomyConfig(datasets.BuilderConfig):
"""BuilderConfig for ISCO ESCO Taxonomy."""
def __init__(self, **kwargs):
"""BuilderConfig for SQUAD.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(IscoEscoTaxonomyConfig, self).__init__(**kwargs)
class IscoEscoTaxonomy(datasets.GeneratorBasedBuilder):
"""The ISCO ESCO Occupations Taxonomy Dataset v1.0.0"""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="isco_1-2",
version=datasets.Version("1.0.0", ""),
description="ISCO hierarchy levels 1-2",
),
]
BUILDER_CONFIG_CLASS = IscoEscoTaxonomyConfig
DEFAULT_CONFIG_NAME = "default"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("string"),
"entailment": datasets.features.Sequence(
{
"ISCO_DEFINITION_1": datasets.Value("string"),
"ISCO_CODE_1": datasets.ClassLabel(names_file="labels/isco_code_1.txt"),
"ISCO_LABEL_1": datasets.Value("string"),
"ESCO_DESCRIPTION": datasets.Value("string"),
}
),
}
),
)
def _info(self):
cwd=os.getcwd()
script_dir = os.path.join(cwd)
return datasets.DatasetInfo(
description="The ISCO ESCO Occupations Taxonomy Dataset",
citation=CITATION,
homepage=HOMEPAGE_URL,
license=LICENSE,
builder_name="isco_esco_occupations",
supervised_keys=None,
task_templates=[
TextClassification(task="text-classification", text_column="ESCO_DESCRIPTION", label_column="ESCO_OCCUPATION"),
# TaskTemplate("text-to-text", text_column="ESCO_DESCRIPTION", summary_column="ESCO_OCCUPATION"),
],
features=Features({
"ISCO_CODE_1": ClassLabel(names_file=os.path.join(cwd, "../", "isco_esco_occupations_taxonomy", "labels", "isco_code_1.txt")),
# "ISCO_CODE_1": ClassLabel(names_file=os.path.join(script_dir, "../", "isco_esco_occupations_taxonomy", "labels", "isco_code_1.txt")),
"ISCO_LABEL_1": ClassLabel(names_file="labels/isco_label_1.txt"),
"ISCO_DEFINITION_1": Value("string"),
"ISCO_CODE_2": ClassLabel(names_file="labels/isco_code_2.txt"),
"ISCO_LABEL_2": ClassLabel(names_file="labels/isco_label_2.txt"),
"ISCO_DEFINITION_2": Value("string"),
"ISCO_CODE_3": ClassLabel(names_file="labels/isco_code_3.txt"),
"ISCO_LABEL_3": ClassLabel(names_file="labels/isco_label_3.txt"),
"ISCO_DEFINITION_3": Value("string"),
"ISCO_CODE_4": ClassLabel(names_file="labels/isco_code_4.txt"),
"ISCO_LABEL_4": ClassLabel(names_file="labels/isco_label_4.txt"),
"ISCO_DEFINITION_4": Value("string"),
"ISCO_CODES": ClassLabel(names_file="labels/isco_codes.txt"),
"ISCO_LABELS": ClassLabel(names_file="labels/isco_labels.txt"),
"ESCO_CODE": ClassLabel(names_file="labels/esco_code.txt"),
"ESCO_LABELS": ClassLabel(names_file="labels/esco_labels.txt"),
"ESCO_OCCUPATION": ClassLabel(names_file="labels/esco_occupation.txt"),
"ESCO_DESCRIPTION": Value("string"),
"LANGUAGE": ClassLabel(names_file="labels/language.txt"),
'isco1': Sequence(
feature={
'ISCO_DEFINITION_1': Value(dtype='large_string'),
'ISCO_CODE_1': ClassLabel(names_file="labels/isco_code_1.txt"),
'ISCO_LABEL_1': ClassLabel(names_file="labels/isco_label_1.txt")
}
)
}))
def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
isco_esco_all = dl_manager.download_and_extract(DOWNLOAD_URL)
return [
SplitGenerator(name=datasets.Split.ALL, gen_kwargs={"filepaths": isco_esco_all}),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
logger.info("generating examples from = %s", filepath)
df = pd.read_parquet(filepath)
for i, row in df.iterrows():
yield i, row.to_dict()
|