shivangibithel
commited on
Commit
•
36cb928
1
Parent(s):
428e4a2
Update SOTAB.py
Browse files
SOTAB.py
CHANGED
@@ -1,20 +1,6 @@
|
|
1 |
import os
|
2 |
import pandas as pd
|
3 |
import datasets
|
4 |
-
|
5 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
6 |
-
_CITATION = """"""
|
7 |
-
|
8 |
-
_DESCRIPTION = """"""
|
9 |
-
|
10 |
-
_HOMEPAGE = ""
|
11 |
-
|
12 |
-
_LICENSE = "CC-BY-SA-4.0 License"
|
13 |
-
|
14 |
-
_URL = ""
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
def _read_table_from_file(table_name: str, root_dir: str)-> dict:
|
19 |
df_ = pd.read_json(os.path.join(root_dir, table_name), compression='gzip', lines=True)
|
20 |
df_ = df_.astype(str)
|
@@ -38,31 +24,8 @@ def _read_table_from_file(table_name: str, root_dir: str)-> dict:
|
|
38 |
|
39 |
|
40 |
class SOTAB(datasets.GeneratorBasedBuilder):
|
41 |
-
"""The
|
42 |
-
|
43 |
-
def _info(self):
|
44 |
-
return datasets.DatasetInfo(
|
45 |
-
description=_DESCRIPTION,
|
46 |
-
features = datasets.Features(
|
47 |
-
{
|
48 |
-
# "id": datasets.Value("int32"),
|
49 |
-
"column_index": datasets.Value("string"),
|
50 |
-
"label": datasets.Value("string"),
|
51 |
-
"table": {
|
52 |
-
"header": datasets.features.Sequence(datasets.Value("string")),
|
53 |
-
"rows": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
|
54 |
-
"name": datasets.Value("string"),
|
55 |
-
},
|
56 |
-
}
|
57 |
-
),
|
58 |
-
supervised_keys=None,
|
59 |
-
homepage=_HOMEPAGE,
|
60 |
-
license=_LICENSE,
|
61 |
-
citation=_CITATION,
|
62 |
-
)
|
63 |
-
|
64 |
def _split_generators(self, dl_manager):
|
65 |
-
"""Returns SplitGenerators."""
|
66 |
train_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Training.zip"
|
67 |
dev_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Validation.zip"
|
68 |
test_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Test.zip"
|
@@ -74,10 +37,6 @@ class SOTAB(datasets.GeneratorBasedBuilder):
|
|
74 |
CTA_Training = os.path.join(dl_manager.download_and_extract(train_url))
|
75 |
CTA_Validation = os.path.join(dl_manager.download_and_extract(dev_url))
|
76 |
CTA_Test = os.path.join(dl_manager.download_and_extract(test_url))
|
77 |
-
|
78 |
-
train_file = "CTA_training_gt.csv"
|
79 |
-
test_file = "CTA_test_gt.csv"
|
80 |
-
dev_file = "CTA_validation_gt.csv"
|
81 |
|
82 |
return [
|
83 |
datasets.SplitGenerator(
|
@@ -88,12 +47,12 @@ class SOTAB(datasets.GeneratorBasedBuilder):
|
|
88 |
datasets.SplitGenerator(
|
89 |
name=datasets.Split.TEST,
|
90 |
# These kwargs will be passed to _generate_examples
|
91 |
-
gen_kwargs={"main_filepath": os.path.join(
|
92 |
),
|
93 |
datasets.SplitGenerator(
|
94 |
name=datasets.Split.VALIDATION,
|
95 |
# These kwargs will be passed to _generate_examples
|
96 |
-
gen_kwargs={"main_filepath": os.path.join(
|
97 |
),
|
98 |
]
|
99 |
|
@@ -104,12 +63,16 @@ class SOTAB(datasets.GeneratorBasedBuilder):
|
|
104 |
if idx == 0:
|
105 |
continue
|
106 |
table_name, column_index, label = line.strip("\n").split(",")
|
|
|
107 |
yield idx, {
|
108 |
"column_index": column_index,
|
109 |
"label": label,
|
110 |
"table": _read_table_from_file(table_name, root_dir),
|
111 |
}
|
112 |
|
|
|
|
|
|
|
113 |
# # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
114 |
# #
|
115 |
# # Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
1 |
import os
|
2 |
import pandas as pd
|
3 |
import datasets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
def _read_table_from_file(table_name: str, root_dir: str)-> dict:
|
5 |
df_ = pd.read_json(os.path.join(root_dir, table_name), compression='gzip', lines=True)
|
6 |
df_ = df_.astype(str)
|
|
|
24 |
|
25 |
|
26 |
class SOTAB(datasets.GeneratorBasedBuilder):
|
27 |
+
"""The SOTAB dataset"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def _split_generators(self, dl_manager):
|
|
|
29 |
train_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Training.zip"
|
30 |
dev_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Validation.zip"
|
31 |
test_url = "https://data.dws.informatik.uni-mannheim.de/structureddata/sotab/CTA_Test.zip"
|
|
|
37 |
CTA_Training = os.path.join(dl_manager.download_and_extract(train_url))
|
38 |
CTA_Validation = os.path.join(dl_manager.download_and_extract(dev_url))
|
39 |
CTA_Test = os.path.join(dl_manager.download_and_extract(test_url))
|
|
|
|
|
|
|
|
|
40 |
|
41 |
return [
|
42 |
datasets.SplitGenerator(
|
|
|
47 |
datasets.SplitGenerator(
|
48 |
name=datasets.Split.TEST,
|
49 |
# These kwargs will be passed to _generate_examples
|
50 |
+
gen_kwargs={"main_filepath": os.path.join(CTA_Validation, test_file), "root_dir": os.path.join(CTA_Validation, "Test")},
|
51 |
),
|
52 |
datasets.SplitGenerator(
|
53 |
name=datasets.Split.VALIDATION,
|
54 |
# These kwargs will be passed to _generate_examples
|
55 |
+
gen_kwargs={"main_filepath": os.path.join(CTA_Test, dev_file), "root_dir": os.path.join(CTA_Test, "Validation")},
|
56 |
),
|
57 |
]
|
58 |
|
|
|
63 |
if idx == 0:
|
64 |
continue
|
65 |
table_name, column_index, label = line.strip("\n").split(",")
|
66 |
+
print(table_name, column_index, label)
|
67 |
yield idx, {
|
68 |
"column_index": column_index,
|
69 |
"label": label,
|
70 |
"table": _read_table_from_file(table_name, root_dir),
|
71 |
}
|
72 |
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
# # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
77 |
# #
|
78 |
# # Licensed under the Apache License, Version 2.0 (the "License");
|