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