shivangibithel commited on
Commit
d6a4b35
1 Parent(s): bdf084c

Upload 6 files

Browse files
Files changed (6) hide show
  1. msato_cv_0.csv +0 -0
  2. msato_cv_1.csv +0 -0
  3. msato_cv_2.csv +0 -0
  4. msato_cv_3.csv +0 -0
  5. msato_cv_4.csv +0 -0
  6. sato.py +90 -0
msato_cv_0.csv ADDED
The diff for this file is too large to render. See raw diff
 
msato_cv_1.csv ADDED
The diff for this file is too large to render. See raw diff
 
msato_cv_2.csv ADDED
The diff for this file is too large to render. See raw diff
 
msato_cv_3.csv ADDED
The diff for this file is too large to render. See raw diff
 
msato_cv_4.csv ADDED
The diff for this file is too large to render. See raw diff
 
sato.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas as pd
3
+ import datasets
4
+
5
+ class sato(datasets.GeneratorBasedBuilder):
6
+ """The sato dataset"""
7
+
8
+ def _info(self):
9
+ features = datasets.Features(
10
+ {
11
+ "table_id": datasets.Value("string"),
12
+ "col_idx": datasets.Value("string"),
13
+ "label": datasets.Value("string"),
14
+ "label_id": datasets.Value("string"),
15
+ "data": datasets.Value("string"),
16
+ }
17
+ )
18
+
19
+ # datasets.value -- single value
20
+ # datasets.features.Sequence -- list
21
+
22
+ return datasets.DatasetInfo(
23
+ features=features
24
+ )
25
+
26
+ def _split_generators(self, dl_manager):
27
+ sato_data = "./sato/data"
28
+
29
+ train_file1 = "msato_cv_0.csv"
30
+ train_file2 = "msato_cv_1.csv"
31
+ train_file3 = "msato_cv_2.csv"
32
+ dev_file = "msato_cv_3.csv"
33
+ test_file = "msato_cv_4.csv"
34
+
35
+ return [
36
+ datasets.SplitGenerator(
37
+ name=datasets.Split.TRAIN,
38
+ # These kwargs will be passed to _generate_examples
39
+ gen_kwargs={"main_filepath": os.path.join(sato_data, train_file1)},
40
+ ),
41
+ datasets.SplitGenerator(
42
+ name=datasets.Split.TEST,
43
+ # These kwargs will be passed to _generate_examples
44
+ gen_kwargs={"main_filepath": os.path.join(sato_data, test_file)},
45
+ ),
46
+ datasets.SplitGenerator(
47
+ name=datasets.Split.VALIDATION,
48
+ # These kwargs will be passed to _generate_examples
49
+ gen_kwargs={"main_filepath": os.path.join(sato_data, dev_file)},
50
+ ),
51
+ ]
52
+
53
+ def _generate_examples(self, main_filepath):
54
+ df = pd.read_csv(main_filepath, encoding="utf8")
55
+ # df = df.astype({'table_id':'string','column_index':'string', 'label':'string'})
56
+ for ind in df.index:
57
+ if ind == 10:
58
+ break
59
+ # print(df.iloc[ind])
60
+ table_id = df['table_id'][ind]
61
+ col_idx = df['col_idx'][ind]
62
+ label = df['class'][ind]
63
+ label_id = df['class_id'][ind]
64
+ data = df['data'][ind]
65
+ yield ind, {
66
+ "table_id": table_id,
67
+ "col_idx":col_idx,
68
+ "label": label,
69
+ "label_id": label_id,
70
+ "data": data,
71
+ }
72
+
73
+ # with open(main_filepath, encoding="utf-8") as f:
74
+ # for idx, line in enumerate(f):
75
+ # # skip the header
76
+ # # table_id,col_idx,class,class_id,data
77
+ # if idx == 0:
78
+ # continue
79
+ # if idx == 100:
80
+ # break
81
+ # print(line)
82
+ # table_id, col_idx, label, label_id, data = line.strip("\n").split(",")
83
+ # print(table_id, col_idx, label, label_id, data)
84
+ # yield idx, {
85
+ # "table_id": table_id,
86
+ # "col_idx":col_idx,
87
+ # "label": label,
88
+ # "label_id": label_id,
89
+ # "data": data,
90
+ # }