Datasets:
link
Browse files- .history/IE_SemParse_20230708000306.py +161 -0
- .history/IE_SemParse_20230708001652.py +161 -0
- IE_SemParse.py +1 -1
.history/IE_SemParse_20230708000306.py
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
58 |
+
class IE_SemParseConfig(datasets.BuilderConfig):
|
59 |
+
"""BuilderConfig for IE-SemParse."""
|
60 |
+
|
61 |
+
def __init__(self, dataset: str, language: str, **kwargs):
|
62 |
+
"""BuilderConfig for IE-SemParse.
|
63 |
+
|
64 |
+
Args:
|
65 |
+
language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
|
66 |
+
**kwargs: keyword arguments forwarded to super.
|
67 |
+
"""
|
68 |
+
super(IE_SemParseConfig, self).__init__(**kwargs)
|
69 |
+
|
70 |
+
self.dataset = dataset
|
71 |
+
self.language = language
|
72 |
+
self.languages = _LANGUAGES
|
73 |
+
self.datasets = _DATASETS
|
74 |
+
|
75 |
+
self._URLS = [os.path.join(
|
76 |
+
_URL, "unfiltered_data", dataset, f"{language}.json")]
|
77 |
+
|
78 |
+
|
79 |
+
class IE_SemParse(datasets.GeneratorBasedBuilder):
|
80 |
+
"""IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
|
81 |
+
|
82 |
+
VERSION = datasets.Version("1.0.0", "")
|
83 |
+
BUILDER_CONFIG_CLASS = IE_SemParseConfig
|
84 |
+
BUILDER_CONFIGS = [
|
85 |
+
IE_SemParseConfig(
|
86 |
+
name=f"{dataset}_{language}",
|
87 |
+
language=language,
|
88 |
+
dataset=dataset,
|
89 |
+
version=datasets.Version("1.0.0", ""),
|
90 |
+
description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
|
91 |
+
)
|
92 |
+
for language, dataset in zip(_LANGUAGES, _DATASETS)
|
93 |
+
]
|
94 |
+
|
95 |
+
def _info(self):
|
96 |
+
dl_manager = datasets.DownloadManager()
|
97 |
+
|
98 |
+
urls_to_download = self.config._URLS
|
99 |
+
|
100 |
+
filepath = dl_manager.download_and_extract(urls_to_download)[0]
|
101 |
+
|
102 |
+
with open(filepath, "r") as f:
|
103 |
+
data = json.load(f)
|
104 |
+
|
105 |
+
features = datasets.Features(
|
106 |
+
{k: datasets.Value("string") for k in data['train'][0].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 |
+
"filepath": downloaded_file,
|
130 |
+
"data_format": "IE-SemParse"
|
131 |
+
},
|
132 |
+
),
|
133 |
+
datasets.SplitGenerator(
|
134 |
+
name=datasets.Split.TEST,
|
135 |
+
gen_kwargs={
|
136 |
+
"split_key": "test",
|
137 |
+
"filepath": downloaded_file,
|
138 |
+
"data_format": "IE-SemParse"
|
139 |
+
},
|
140 |
+
),
|
141 |
+
datasets.SplitGenerator(
|
142 |
+
name=datasets.Split.VALIDATION,
|
143 |
+
gen_kwargs={
|
144 |
+
"split_key": "val",
|
145 |
+
"filepath": downloaded_file,
|
146 |
+
"data_format": "IE-SemParse"
|
147 |
+
},
|
148 |
+
),
|
149 |
+
]
|
150 |
+
|
151 |
+
def _generate_examples(self, data_format, split_key, filepath):
|
152 |
+
"""This function returns the examples in the raw (text) form."""
|
153 |
+
|
154 |
+
with open(filepath, "r") as f:
|
155 |
+
data = json.load(f)
|
156 |
+
data = data[split_key]
|
157 |
+
|
158 |
+
for idx, row in enumerate(data):
|
159 |
+
yield idx, {
|
160 |
+
k: v for k, v in row.items()
|
161 |
+
}
|
.history/IE_SemParse_20230708001652.py
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
58 |
+
class IE_SemParseConfig(datasets.BuilderConfig):
|
59 |
+
"""BuilderConfig for IE-SemParse."""
|
60 |
+
|
61 |
+
def __init__(self, dataset: str, language: str, **kwargs):
|
62 |
+
"""BuilderConfig for IE-SemParse.
|
63 |
+
|
64 |
+
Args:
|
65 |
+
language: One of hi, bn, mr, as, ta, te, or, ml, pa, gu, kn
|
66 |
+
**kwargs: keyword arguments forwarded to super.
|
67 |
+
"""
|
68 |
+
super(IE_SemParseConfig, self).__init__(**kwargs)
|
69 |
+
|
70 |
+
self.dataset = dataset
|
71 |
+
self.language = language
|
72 |
+
self.languages = _LANGUAGES
|
73 |
+
self.datasets = _DATASETS
|
74 |
+
|
75 |
+
self._URLS = [os.path.join(
|
76 |
+
_URL, "unfiltered_data", dataset, f"{language}.json")]
|
77 |
+
|
78 |
+
|
79 |
+
class IE_SemParse(datasets.GeneratorBasedBuilder):
|
80 |
+
"""IE-SemParse: Inter-Bilingual Semantic Parsing Dataset for Indic Languages. Version 1.0."""
|
81 |
+
|
82 |
+
VERSION = datasets.Version("1.0.0", "")
|
83 |
+
BUILDER_CONFIG_CLASS = IE_SemParseConfig
|
84 |
+
BUILDER_CONFIGS = [
|
85 |
+
IE_SemParseConfig(
|
86 |
+
name=f"{dataset}_{language}",
|
87 |
+
language=language,
|
88 |
+
dataset=dataset,
|
89 |
+
version=datasets.Version("1.0.0", ""),
|
90 |
+
description=f"Plain text import of IE-SemParse for the {language} language for {dataset} dataset",
|
91 |
+
)
|
92 |
+
for language, dataset in zip(_LANGUAGES, _DATASETS)
|
93 |
+
]
|
94 |
+
|
95 |
+
def _info(self):
|
96 |
+
dl_manager = datasets.DownloadManager()
|
97 |
+
|
98 |
+
urls_to_download = self.config._URLS
|
99 |
+
|
100 |
+
filepath = dl_manager.download_and_extract(urls_to_download)[0]
|
101 |
+
|
102 |
+
with open(filepath, "r") as f:
|
103 |
+
data = json.load(f)
|
104 |
+
|
105 |
+
features = datasets.Features(
|
106 |
+
{k: datasets.Value("string") for k in data['train'][0].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 |
+
"filepath": downloaded_file,
|
130 |
+
"data_format": "IE-SemParse"
|
131 |
+
},
|
132 |
+
),
|
133 |
+
datasets.SplitGenerator(
|
134 |
+
name=datasets.Split.TEST,
|
135 |
+
gen_kwargs={
|
136 |
+
"split_key": "test",
|
137 |
+
"filepath": downloaded_file,
|
138 |
+
"data_format": "IE-SemParse"
|
139 |
+
},
|
140 |
+
),
|
141 |
+
datasets.SplitGenerator(
|
142 |
+
name=datasets.Split.VALIDATION,
|
143 |
+
gen_kwargs={
|
144 |
+
"split_key": "val",
|
145 |
+
"filepath": downloaded_file,
|
146 |
+
"data_format": "IE-SemParse"
|
147 |
+
},
|
148 |
+
),
|
149 |
+
]
|
150 |
+
|
151 |
+
def _generate_examples(self, data_format, split_key, filepath):
|
152 |
+
"""This function returns the examples in the raw (text) form."""
|
153 |
+
|
154 |
+
with open(filepath, "r") as f:
|
155 |
+
data = json.load(f)
|
156 |
+
data = data[split_key]
|
157 |
+
|
158 |
+
for idx, row in enumerate(data):
|
159 |
+
yield idx, {
|
160 |
+
k: v for k, v in row.items()
|
161 |
+
}
|
IE_SemParse.py
CHANGED
@@ -52,7 +52,7 @@ _DATASETS = (
|
|
52 |
)
|
53 |
|
54 |
|
55 |
-
_URL = "https://huggingface.co/datasets/Divyanshu/
|
56 |
|
57 |
|
58 |
class IE_SemParseConfig(datasets.BuilderConfig):
|
|
|
52 |
)
|
53 |
|
54 |
|
55 |
+
_URL = "https://huggingface.co/datasets/Divyanshu/IE_SemParse/resolve/main/"
|
56 |
|
57 |
|
58 |
class IE_SemParseConfig(datasets.BuilderConfig):
|