Datasets:
Update ViHOS.py
Browse files
ViHOS.py
CHANGED
|
@@ -47,37 +47,21 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
| 47 |
"split": "test",
|
| 48 |
},
|
| 49 |
)
|
| 50 |
-
]
|
| 51 |
-
def load_csv(filename):
|
| 52 |
-
data = list()
|
| 53 |
-
# Open file in read mode
|
| 54 |
-
file = open(filename,"r")
|
| 55 |
-
# Reading file
|
| 56 |
-
lines = reader(file)
|
| 57 |
-
csv_reader = reader(file)
|
| 58 |
-
for row in csv_reader:
|
| 59 |
-
if not row:
|
| 60 |
-
continue
|
| 61 |
-
data.append(row)
|
| 62 |
-
|
| 63 |
-
return data
|
| 64 |
-
|
| 65 |
def _generate_examples(self, filepath, split):
|
| 66 |
colnames=['id', 'Content', 'Span ids']
|
| 67 |
|
| 68 |
data = pd.read_csv(filepath, names=colnames, header=None, sep=",", on_bad_lines='skip')
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
# }
|
| 80 |
-
yield data
|
| 81 |
|
| 82 |
# data = pd.read_csv(filepath, colnames=colnames, header = None)
|
| 83 |
# yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]
|
|
|
|
| 47 |
"split": "test",
|
| 48 |
},
|
| 49 |
)
|
| 50 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def _generate_examples(self, filepath, split):
|
| 52 |
colnames=['id', 'Content', 'Span ids']
|
| 53 |
|
| 54 |
data = pd.read_csv(filepath, names=colnames, header=None, sep=",", on_bad_lines='skip')
|
| 55 |
|
| 56 |
+
for i in range(len(data)):
|
| 57 |
+
id_ = data.loc[i, 'id']
|
| 58 |
+
content = data.loc[i, 'Content']
|
| 59 |
+
span_ids = data.loc[i, 'Span ids']
|
| 60 |
|
| 61 |
+
yield id_, {
|
| 62 |
+
"content": content,
|
| 63 |
+
"span_ids": span_ids,
|
| 64 |
+
}
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# data = pd.read_csv(filepath, colnames=colnames, header = None)
|
| 67 |
# yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]
|