Divyanshu commited on
Commit
469ce3f
·
1 Parent(s): 77da6f3
.history/IE_SemParse_20230708002010.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+
4
+ # Lint as: python3
5
+ """IE-SemParse: The Cross-Lingual NLI Corpus 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
+ mapping = {"itop": "IE-mTOP",
56
+ "indic-atis": "IE-ATIS",
57
+ "indic-TOP": "IE-multilingualTOP"}
58
+
59
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
60
+
61
+
62
+ class IE_SemParseConfig(datasets.BuilderConfig):
63
+ """BuilderConfig for IE-SemParse."""
64
+
65
+ def __init__(self, dataset: str, language: str, **kwargs):
66
+ """BuilderConfig for IE-SemParse.
67
+
68
+ Args:
69
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
70
+ **kwargs: keyword arguments forwarded to super.
71
+ """
72
+ super(IE_SemParseConfig, self).__init__(**kwargs)
73
+
74
+ self.dataset = dataset
75
+ self.language = language
76
+ self.languages = _LANGUAGES
77
+ self.datasets = _DATASETS
78
+
79
+ self._URLS = [os.path.join(
80
+ _URL, "unfiltered_data", dataset, f"{language}.json")]
81
+
82
+
83
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
84
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
85
+
86
+ VERSION = datasets.Version("1.0.0", "")
87
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
88
+ BUILDER_CONFIGS = [
89
+ IE_SemParseConfig(
90
+ name=f"{mapping[dataset]}_{language}",
91
+ language=language,
92
+ dataset=dataset,
93
+ version=datasets.Version("1.0.0", ""),
94
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
95
+ )
96
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
97
+ ]
98
+
99
+ def _info(self):
100
+ dl_manager = datasets.DownloadManager()
101
+
102
+ urls_to_download = self.config._URLS
103
+
104
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
105
+
106
+ with open(filepath, "r") as f:
107
+ data = json.load(f)
108
+
109
+ features = datasets.Features(
110
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
111
+ )
112
+
113
+ return datasets.DatasetInfo(
114
+ description=_DESCRIPTION,
115
+ features=features,
116
+ # No default supervised_keys (as we have to pass both premise
117
+ # and hypothesis as input).
118
+ supervised_keys=None,
119
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
120
+ citation=_CITATION,
121
+ )
122
+
123
+ def _split_generators(self, dl_manager):
124
+ urls_to_download = self.config._URLS
125
+
126
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
127
+
128
+ return [
129
+ datasets.SplitGenerator(
130
+ name=datasets.Split.TRAIN,
131
+ gen_kwargs={
132
+ "split_key": "train",
133
+ "filepath": downloaded_file,
134
+ "data_format": "IE-SemParse"
135
+ },
136
+ ),
137
+ datasets.SplitGenerator(
138
+ name=datasets.Split.TEST,
139
+ gen_kwargs={
140
+ "split_key": "test",
141
+ "filepath": downloaded_file,
142
+ "data_format": "IE-SemParse"
143
+ },
144
+ ),
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.VALIDATION,
147
+ gen_kwargs={
148
+ "split_key": "val",
149
+ "filepath": downloaded_file,
150
+ "data_format": "IE-SemParse"
151
+ },
152
+ ),
153
+ ]
154
+
155
+ def _generate_examples(self, data_format, split_key, filepath):
156
+ """This function returns the examples in the raw (text) form."""
157
+
158
+ with open(filepath, "r") as f:
159
+ data = json.load(f)
160
+ data = data[split_key]
161
+
162
+ for idx, row in enumerate(data):
163
+ yield idx, {
164
+ k: v for k, v in row.items()
165
+ }
.history/IE_SemParse_20230708002023.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+
4
+ # Lint as: python3
5
+ """IE-SemParse: The InterBilingual 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
+ mapping = {"itop": "IE-mTOP",
56
+ "indic-atis": "IE-ATIS",
57
+ "indic-TOP": "IE-multilingualTOP"}
58
+
59
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
60
+
61
+
62
+ class IE_SemParseConfig(datasets.BuilderConfig):
63
+ """BuilderConfig for IE-SemParse."""
64
+
65
+ def __init__(self, dataset: str, language: str, **kwargs):
66
+ """BuilderConfig for IE-SemParse.
67
+
68
+ Args:
69
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
70
+ **kwargs: keyword arguments forwarded to super.
71
+ """
72
+ super(IE_SemParseConfig, self).__init__(**kwargs)
73
+
74
+ self.dataset = dataset
75
+ self.language = language
76
+ self.languages = _LANGUAGES
77
+ self.datasets = _DATASETS
78
+
79
+ self._URLS = [os.path.join(
80
+ _URL, "unfiltered_data", dataset, f"{language}.json")]
81
+
82
+
83
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
84
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
85
+
86
+ VERSION = datasets.Version("1.0.0", "")
87
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
88
+ BUILDER_CONFIGS = [
89
+ IE_SemParseConfig(
90
+ name=f"{mapping[dataset]}_{language}",
91
+ language=language,
92
+ dataset=dataset,
93
+ version=datasets.Version("1.0.0", ""),
94
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
95
+ )
96
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
97
+ ]
98
+
99
+ def _info(self):
100
+ dl_manager = datasets.DownloadManager()
101
+
102
+ urls_to_download = self.config._URLS
103
+
104
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
105
+
106
+ with open(filepath, "r") as f:
107
+ data = json.load(f)
108
+
109
+ features = datasets.Features(
110
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
111
+ )
112
+
113
+ return datasets.DatasetInfo(
114
+ description=_DESCRIPTION,
115
+ features=features,
116
+ # No default supervised_keys (as we have to pass both premise
117
+ # and hypothesis as input).
118
+ supervised_keys=None,
119
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
120
+ citation=_CITATION,
121
+ )
122
+
123
+ def _split_generators(self, dl_manager):
124
+ urls_to_download = self.config._URLS
125
+
126
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
127
+
128
+ return [
129
+ datasets.SplitGenerator(
130
+ name=datasets.Split.TRAIN,
131
+ gen_kwargs={
132
+ "split_key": "train",
133
+ "filepath": downloaded_file,
134
+ "data_format": "IE-SemParse"
135
+ },
136
+ ),
137
+ datasets.SplitGenerator(
138
+ name=datasets.Split.TEST,
139
+ gen_kwargs={
140
+ "split_key": "test",
141
+ "filepath": downloaded_file,
142
+ "data_format": "IE-SemParse"
143
+ },
144
+ ),
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.VALIDATION,
147
+ gen_kwargs={
148
+ "split_key": "val",
149
+ "filepath": downloaded_file,
150
+ "data_format": "IE-SemParse"
151
+ },
152
+ ),
153
+ ]
154
+
155
+ def _generate_examples(self, data_format, split_key, filepath):
156
+ """This function returns the examples in the raw (text) form."""
157
+
158
+ with open(filepath, "r") as f:
159
+ data = json.load(f)
160
+ data = data[split_key]
161
+
162
+ for idx, row in enumerate(data):
163
+ yield idx, {
164
+ k: v for k, v in row.items()
165
+ }
.history/IE_SemParse_20230708002025.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ mapping = {"itop": "IE-mTOP",
56
+ "indic-atis": "IE-ATIS",
57
+ "indic-TOP": "IE-multilingualTOP"}
58
+
59
+ _URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
60
+
61
+
62
+ class IE_SemParseConfig(datasets.BuilderConfig):
63
+ """BuilderConfig for IE-SemParse."""
64
+
65
+ def __init__(self, dataset: str, language: str, **kwargs):
66
+ """BuilderConfig for IE-SemParse.
67
+
68
+ Args:
69
+ language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
70
+ **kwargs: keyword arguments forwarded to super.
71
+ """
72
+ super(IE_SemParseConfig, self).__init__(**kwargs)
73
+
74
+ self.dataset = dataset
75
+ self.language = language
76
+ self.languages = _LANGUAGES
77
+ self.datasets = _DATASETS
78
+
79
+ self._URLS = [os.path.join(
80
+ _URL, "unfiltered_data", dataset, f"{language}.json")]
81
+
82
+
83
+ class IE_SemParse(datasets.GeneratorBasedBuilder):
84
+ """IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
85
+
86
+ VERSION = datasets.Version("1.0.0", "")
87
+ BUILDER_CONFIG_CLASS = IE_SemParseConfig
88
+ BUILDER_CONFIGS = [
89
+ IE_SemParseConfig(
90
+ name=f"{mapping[dataset]}_{language}",
91
+ language=language,
92
+ dataset=dataset,
93
+ version=datasets.Version("1.0.0", ""),
94
+ description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
95
+ )
96
+ for language, dataset in zip(_LANGUAGES, _DATASETS)
97
+ ]
98
+
99
+ def _info(self):
100
+ dl_manager = datasets.DownloadManager()
101
+
102
+ urls_to_download = self.config._URLS
103
+
104
+ filepath = dl_manager.download_and_extract(urls_to_download)[0]
105
+
106
+ with open(filepath, "r") as f:
107
+ data = json.load(f)
108
+
109
+ features = datasets.Features(
110
+ {k: datasets.Value("string") for k in data['train'][0].keys()}
111
+ )
112
+
113
+ return datasets.DatasetInfo(
114
+ description=_DESCRIPTION,
115
+ features=features,
116
+ # No default supervised_keys (as we have to pass both premise
117
+ # and hypothesis as input).
118
+ supervised_keys=None,
119
+ homepage="https://github.com/divyanshuaggarwal/IE-SemParse",
120
+ citation=_CITATION,
121
+ )
122
+
123
+ def _split_generators(self, dl_manager):
124
+ urls_to_download = self.config._URLS
125
+
126
+ downloaded_file = dl_manager.download_and_extract(urls_to_download)[0]
127
+
128
+ return [
129
+ datasets.SplitGenerator(
130
+ name=datasets.Split.TRAIN,
131
+ gen_kwargs={
132
+ "split_key": "train",
133
+ "filepath": downloaded_file,
134
+ "data_format": "IE-SemParse"
135
+ },
136
+ ),
137
+ datasets.SplitGenerator(
138
+ name=datasets.Split.TEST,
139
+ gen_kwargs={
140
+ "split_key": "test",
141
+ "filepath": downloaded_file,
142
+ "data_format": "IE-SemParse"
143
+ },
144
+ ),
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.VALIDATION,
147
+ gen_kwargs={
148
+ "split_key": "val",
149
+ "filepath": downloaded_file,
150
+ "data_format": "IE-SemParse"
151
+ },
152
+ ),
153
+ ]
154
+
155
+ def _generate_examples(self, data_format, split_key, filepath):
156
+ """This function returns the examples in the raw (text) form."""
157
+
158
+ with open(filepath, "r") as f:
159
+ data = json.load(f)
160
+ data = data[split_key]
161
+
162
+ for idx, row in enumerate(data):
163
+ yield idx, {
164
+ k: v for k, v in row.items()
165
+ }
IE_SemParse.py CHANGED
@@ -2,7 +2,7 @@
2
 
3
 
4
  # Lint as: python3
5
- """IndicXNLI: The Cross-Lingual NLI Corpus for Indic Languages."""
6
 
7
 
8
  import os
 
2
 
3
 
4
  # Lint as: python3
5
+ """IE-SemParse: The Inter-Bilingual Semantic Parsing for Indic Languages."""
6
 
7
 
8
  import os