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