Daniel Duckworth commited on
Commit
d2c5b2b
1 Parent(s): 740dfc3

checkpoint

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