Divyanshu commited on
Commit
6278733
1 Parent(s): 9d1b6bc

clean code phew

Browse files
.history/IE_SemParse_20230714000459.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+
4
+ # Lint as: python3
5
+ """IE-SemParse: The Inter-Bilingual Semantic Parsing for Indic Languages."""
6
+
7
+
8
+ import os
9
+ import json
10
+
11
+ import pandas as pd
12
+
13
+ import datasets
14
+
15
+ from datasets import DownloadManager
16
+
17
+
18
+ _CITATION = """\
19
+ @misc{aggarwal2023evaluating,
20
+ title={Evaluating Inter-Bilingual Semantic Parsing for Indian Languages},
21
+ author={Divyanshu Aggarwal and Vivek Gupta and Anoop Kunchukuttan},
22
+ year={2023},
23
+ eprint={2304.13005},
24
+ archivePrefix={arXiv},
25
+ primaryClass={cs.CL}
26
+ }
27
+ """
28
+
29
+ _DESCRIPTION = """\
30
+ IE-SemParse is an Inter-bilingual Seq2seq Semantic parsing dataset for 11 distinct Indian languages
31
+ """
32
+
33
+ _LANGUAGES = (
34
+ 'hi',
35
+ 'bn',
36
+ 'mr',
37
+ 'as',
38
+ 'ta',
39
+ 'te',
40
+ 'or',
41
+ 'ml',
42
+ 'pa',
43
+ 'gu',
44
+ 'kn'
45
+ )
46
+
47
+
48
+ # _DATASETS = (
49
+ # 'itop',
50
+ # 'indic-atis',
51
+ # 'indic-TOP'
52
+ # )
53
+
54
+
55
+ _DATASETS = (
56
+ "IE-mTOP",
57
+ "IE-ATIS",
58
+ "IE-multilingualTOP"
59
+ )
60
+
61
+ mapping = {"IE-mTOP": "itop",
62
+ "IE-ATIS": "indic-atis",
63
+ "IE-multilingualTOP": "indic-TOP"}
64
+
65
+
66
+
67
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
68
+
69
+
70
+ class IE_SemParseConfig(datasets.BuilderConfig):
71
+ """BuilderConfig for IE-SemParse."""
72
+
73
+ def __init__(self, dataset: str, language: str, **kwargs):
74
+ """BuilderConfig for IE-SemParse.
75
+
76
+ Args:
77
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
78
+ **kwargs: keyword arguments forwarded to super.
79
+ """
80
+ super(IE_SemParseConfig, self).__init__(**kwargs)
81
+
82
+ self.dataset = dataset
83
+ self.language = language
84
+ self.languages = _LANGUAGES
85
+ self.datasets = _DATASETS
86
+
87
+ self._URLS = [os.path.join(
88
+ _URL, "unfiltered_data", mapping[dataset], f"{language}.json")]
89
+
90
+
91
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
92
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
93
+
94
+ VERSION = datasets.Version("1.0.0", "")
95
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
96
+ BUILDER_CONFIGS = [
97
+ IE_SemParseConfig(
98
+ name=f"{dataset}_{language}",
99
+ language=language,
100
+ dataset=dataset,
101
+ version=datasets.Version("1.0.0", ""),
102
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
103
+ )
104
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
105
+ ]
106
+
107
+ def _info(self):
108
+ dl_manager = datasets.DownloadManager()
109
+
110
+ urls_to_download = self.config._URLS
111
+
112
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
113
+
114
+ with open(filepath, "r") as f:
115
+ data = json.load(f)
116
+
117
+ features = datasets.Features(
118
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
119
+ )
120
+
121
+ return datasets.DatasetInfo(
122
+ description=_DESCRIPTION,
123
+ features=features,
124
+ # No default supervised_keys (as we have to pass both premise
125
+ # and hypothesis as input).
126
+ supervised_keys=None,
127
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
128
+ citation=_CITATION,
129
+ )
130
+
131
+ def _split_generators(self, dl_manager):
132
+ urls_to_download = self.config._URLS
133
+
134
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
135
+
136
+ return [
137
+ datasets.SplitGenerator(
138
+ name=datasets.Split.TRAIN,
139
+ gen_kwargs={
140
+ "split_key": "train",
141
+ "filepath": downloaded_file,
142
+ "data_format": "IE-SemParse"
143
+ },
144
+ ),
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.TEST,
147
+ gen_kwargs={
148
+ "split_key": "test",
149
+ "filepath": downloaded_file,
150
+ "data_format": "IE-SemParse"
151
+ },
152
+ ),
153
+ datasets.SplitGenerator(
154
+ name=datasets.Split.VALIDATION,
155
+ gen_kwargs={
156
+ "split_key": "validation",
157
+ "filepath": downloaded_file,
158
+ "data_format": "IE-SemParse"
159
+ },
160
+ ),
161
+ ]
162
+
163
+ def _generate_examples(self, data_format, split_key, filepath):
164
+ """This function returns the examples in the raw (text) form."""
165
+
166
+ with open(filepath, "r") as f:
167
+ data = json.load(f)
168
+ data = data[split_key]
169
+
170
+ for idx, row in enumerate(data):
171
+ yield idx, {
172
+ k: v for k, v in row.items()
173
+ }
.history/IE_SemParse_20230714000500.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+
4
+ # Lint as: python3
5
+ """IE-SemParse: The Inter-Bilingual Semantic Parsing for Indic Languages."""
6
+
7
+
8
+ import os
9
+ import json
10
+
11
+ import pandas as pd
12
+
13
+ import datasets
14
+
15
+ from datasets import DownloadManager
16
+
17
+
18
+ _CITATION = """\
19
+ @misc{aggarwal2023evaluating,
20
+ title={Evaluating Inter-Bilingual Semantic Parsing for Indian Languages},
21
+ author={Divyanshu Aggarwal and Vivek Gupta and Anoop Kunchukuttan},
22
+ year={2023},
23
+ eprint={2304.13005},
24
+ archivePrefix={arXiv},
25
+ primaryClass={cs.CL}
26
+ }
27
+ """
28
+
29
+ _DESCRIPTION = """\
30
+ IE-SemParse is an Inter-bilingual Seq2seq Semantic parsing dataset for 11 distinct Indian languages
31
+ """
32
+
33
+ _LANGUAGES = (
34
+ 'hi',
35
+ 'bn',
36
+ 'mr',
37
+ 'as',
38
+ 'ta',
39
+ 'te',
40
+ 'or',
41
+ 'ml',
42
+ 'pa',
43
+ 'gu',
44
+ 'kn'
45
+ )
46
+
47
+
48
+ # _DATASETS = (
49
+ # 'itop',
50
+ # 'indic-atis',
51
+ # 'indic-TOP'
52
+ # )
53
+
54
+
55
+ _DATASETS = (
56
+ "IE-mTOP",
57
+ "IE-ATIS",
58
+ "IE-multilingualTOP"
59
+ )
60
+
61
+ mapping = {"IE-mTOP": "itop",
62
+ "IE-ATIS": "indic-atis",
63
+ "IE-multilingualTOP": "indic-TOP"}
64
+
65
+
66
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
67
+
68
+
69
+ class IE_SemParseConfig(datasets.BuilderConfig):
70
+ """BuilderConfig for IE-SemParse."""
71
+
72
+ def __init__(self, dataset: str, language: str, **kwargs):
73
+ """BuilderConfig for IE-SemParse.
74
+
75
+ Args:
76
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
77
+ **kwargs: keyword arguments forwarded to super.
78
+ """
79
+ super(IE_SemParseConfig, self).__init__(**kwargs)
80
+
81
+ self.dataset = dataset
82
+ self.language = language
83
+ self.languages = _LANGUAGES
84
+ self.datasets = _DATASETS
85
+
86
+ self._URLS = [os.path.join(
87
+ _URL, "unfiltered_data", mapping[dataset], f"{language}.json")]
88
+
89
+
90
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
91
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
92
+
93
+ VERSION = datasets.Version("1.0.0", "")
94
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
95
+ BUILDER_CONFIGS = [
96
+ IE_SemParseConfig(
97
+ name=f"{dataset}_{language}",
98
+ language=language,
99
+ dataset=dataset,
100
+ version=datasets.Version("1.0.0", ""),
101
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
102
+ )
103
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
104
+ ]
105
+
106
+ def _info(self):
107
+ dl_manager = datasets.DownloadManager()
108
+
109
+ urls_to_download = self.config._URLS
110
+
111
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
112
+
113
+ with open(filepath, "r") as f:
114
+ data = json.load(f)
115
+
116
+ features = datasets.Features(
117
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
118
+ )
119
+
120
+ return datasets.DatasetInfo(
121
+ description=_DESCRIPTION,
122
+ features=features,
123
+ # No default supervised_keys (as we have to pass both premise
124
+ # and hypothesis as input).
125
+ supervised_keys=None,
126
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
127
+ citation=_CITATION,
128
+ )
129
+
130
+ def _split_generators(self, dl_manager):
131
+ urls_to_download = self.config._URLS
132
+
133
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
134
+
135
+ return [
136
+ datasets.SplitGenerator(
137
+ name=datasets.Split.TRAIN,
138
+ gen_kwargs={
139
+ "split_key": "train",
140
+ "filepath": downloaded_file,
141
+ "data_format": "IE-SemParse"
142
+ },
143
+ ),
144
+ datasets.SplitGenerator(
145
+ name=datasets.Split.TEST,
146
+ gen_kwargs={
147
+ "split_key": "test",
148
+ "filepath": downloaded_file,
149
+ "data_format": "IE-SemParse"
150
+ },
151
+ ),
152
+ datasets.SplitGenerator(
153
+ name=datasets.Split.VALIDATION,
154
+ gen_kwargs={
155
+ "split_key": "validation",
156
+ "filepath": downloaded_file,
157
+ "data_format": "IE-SemParse"
158
+ },
159
+ ),
160
+ ]
161
+
162
+ def _generate_examples(self, data_format, split_key, filepath):
163
+ """This function returns the examples in the raw (text) form."""
164
+
165
+ with open(filepath, "r") as f:
166
+ data = json.load(f)
167
+ data = data[split_key]
168
+
169
+ for idx, row in enumerate(data):
170
+ yield idx, {
171
+ k: v for k, v in row.items()
172
+ }
.history/IE_SemParse_20230714000507.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+
4
+ # Lint as: python3
5
+ """IE-SemParse: The Inter-Bilingual Semantic Parsing for Indic Languages."""
6
+
7
+
8
+ import os
9
+ import json
10
+
11
+ import pandas as pd
12
+
13
+ import datasets
14
+
15
+ from datasets import DownloadManager
16
+
17
+
18
+ _CITATION = """\
19
+ @misc{aggarwal2023evaluating,
20
+ title={Evaluating Inter-Bilingual Semantic Parsing for Indian Languages},
21
+ author={Divyanshu Aggarwal and Vivek Gupta and Anoop Kunchukuttan},
22
+ year={2023},
23
+ eprint={2304.13005},
24
+ archivePrefix={arXiv},
25
+ primaryClass={cs.CL}
26
+ }
27
+ """
28
+
29
+ _DESCRIPTION = """\
30
+ IE-SemParse is an Inter-bilingual Seq2seq Semantic parsing dataset for 11 distinct Indian languages
31
+ """
32
+
33
+ _LANGUAGES = (
34
+ 'hi',
35
+ 'bn',
36
+ 'mr',
37
+ 'as',
38
+ 'ta',
39
+ 'te',
40
+ 'or',
41
+ 'ml',
42
+ 'pa',
43
+ 'gu',
44
+ 'kn'
45
+ )
46
+
47
+
48
+
49
+ _DATASETS = (
50
+ "IE-mTOP",
51
+ "IE-ATIS",
52
+ "IE-multilingualTOP"
53
+ )
54
+
55
+ mapping = {"IE-mTOP": "itop",
56
+ "IE-ATIS": "indic-atis",
57
+ "IE-multilingualTOP": "indic-TOP"}
58
+
59
+
60
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
61
+
62
+
63
+ class IE_SemParseConfig(datasets.BuilderConfig):
64
+ """BuilderConfig for IE-SemParse."""
65
+
66
+ def __init__(self, dataset: str, language: str, **kwargs):
67
+ """BuilderConfig for IE-SemParse.
68
+
69
+ Args:
70
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
71
+ **kwargs: keyword arguments forwarded to super.
72
+ """
73
+ super(IE_SemParseConfig, self).__init__(**kwargs)
74
+
75
+ self.dataset = dataset
76
+ self.language = language
77
+ self.languages = _LANGUAGES
78
+ self.datasets = _DATASETS
79
+
80
+ self._URLS = [os.path.join(
81
+ _URL, "unfiltered_data", mapping[dataset], f"{language}.json")]
82
+
83
+
84
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
85
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
86
+
87
+ VERSION = datasets.Version("1.0.0", "")
88
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
89
+ BUILDER_CONFIGS = [
90
+ IE_SemParseConfig(
91
+ name=f"{dataset}_{language}",
92
+ language=language,
93
+ dataset=dataset,
94
+ version=datasets.Version("1.0.0", ""),
95
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
96
+ )
97
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
98
+ ]
99
+
100
+ def _info(self):
101
+ dl_manager = datasets.DownloadManager()
102
+
103
+ urls_to_download = self.config._URLS
104
+
105
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
106
+
107
+ with open(filepath, "r") as f:
108
+ data = json.load(f)
109
+
110
+ features = datasets.Features(
111
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
112
+ )
113
+
114
+ return datasets.DatasetInfo(
115
+ description=_DESCRIPTION,
116
+ features=features,
117
+ # No default supervised_keys (as we have to pass both premise
118
+ # and hypothesis as input).
119
+ supervised_keys=None,
120
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
121
+ citation=_CITATION,
122
+ )
123
+
124
+ def _split_generators(self, dl_manager):
125
+ urls_to_download = self.config._URLS
126
+
127
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
128
+
129
+ return [
130
+ datasets.SplitGenerator(
131
+ name=datasets.Split.TRAIN,
132
+ gen_kwargs={
133
+ "split_key": "train",
134
+ "filepath": downloaded_file,
135
+ "data_format": "IE-SemParse"
136
+ },
137
+ ),
138
+ datasets.SplitGenerator(
139
+ name=datasets.Split.TEST,
140
+ gen_kwargs={
141
+ "split_key": "test",
142
+ "filepath": downloaded_file,
143
+ "data_format": "IE-SemParse"
144
+ },
145
+ ),
146
+ datasets.SplitGenerator(
147
+ name=datasets.Split.VALIDATION,
148
+ gen_kwargs={
149
+ "split_key": "validation",
150
+ "filepath": downloaded_file,
151
+ "data_format": "IE-SemParse"
152
+ },
153
+ ),
154
+ ]
155
+
156
+ def _generate_examples(self, data_format, split_key, filepath):
157
+ """This function returns the examples in the raw (text) form."""
158
+
159
+ with open(filepath, "r") as f:
160
+ data = json.load(f)
161
+ data = data[split_key]
162
+
163
+ for idx, row in enumerate(data):
164
+ yield idx, {
165
+ k: v for k, v in row.items()
166
+ }
IE_SemParse.py CHANGED
@@ -45,12 +45,6 @@ _LANGUAGES = (
45
  )
46
 
47
 
48
- # _DATASETS = (
49
- # 'itop',
50
- # 'indic-atis',
51
- # 'indic-TOP'
52
- # )
53
-
54
 
55
  _DATASETS = (
56
  "IE-mTOP",
@@ -63,8 +57,6 @@ mapping = {"IE-mTOP": "itop",
63
  "IE-multilingualTOP": "indic-TOP"}
64
 
65
 
66
- reverse_map = {v: k for k, v in mapping.items()}
67
-
68
  _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
69
 
70
 
 
45
  )
46
 
47
 
 
 
 
 
 
 
48
 
49
  _DATASETS = (
50
  "IE-mTOP",
 
57
  "IE-multilingualTOP": "indic-TOP"}
58
 
59
 
 
 
60
  _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
61
 
62