Datasets:
Update ViHOS.py
Browse files
ViHOS.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""ViHOS - Vietnamese Hate and Offensive Spans dataset"""
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
import datasets
|
| 6 |
|
|
@@ -44,7 +44,7 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
| 44 |
name=datasets.Split.TEST,
|
| 45 |
gen_kwargs={
|
| 46 |
"filepath": data_dir[0],
|
| 47 |
-
"split": "
|
| 48 |
},
|
| 49 |
)
|
| 50 |
]
|
|
@@ -63,16 +63,20 @@ class ViHOS(datasets.GeneratorBasedBuilder):
|
|
| 63 |
return data
|
| 64 |
|
| 65 |
def _generate_examples(self, filepath, split):
|
| 66 |
-
|
|
|
|
| 67 |
with open(filepath, 'r', encoding="utf-8") as f:
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
|
| 77 |
# data = pd.read_csv(filepath, colnames=colnames, header = None)
|
| 78 |
# yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]
|
|
|
|
| 1 |
"""ViHOS - Vietnamese Hate and Offensive Spans dataset"""
|
| 2 |
|
| 3 |
+
import pandas as pd
|
| 4 |
|
| 5 |
import datasets
|
| 6 |
|
|
|
|
| 44 |
name=datasets.Split.TEST,
|
| 45 |
gen_kwargs={
|
| 46 |
"filepath": data_dir[0],
|
| 47 |
+
"split": "test",
|
| 48 |
},
|
| 49 |
)
|
| 50 |
]
|
|
|
|
| 63 |
return data
|
| 64 |
|
| 65 |
def _generate_examples(self, filepath, split):
|
| 66 |
+
colnames=['id', 'Content', 'Span ids']
|
| 67 |
+
|
| 68 |
with open(filepath, 'r', encoding="utf-8") as f:
|
| 69 |
+
data = pd.read_csv(f, names=colnames, header = None)
|
| 70 |
+
for i in range(len(data)):
|
| 71 |
+
id = data.loc[i, 'id']
|
| 72 |
+
Content = data.loc[i, 'Content']
|
| 73 |
+
Span_ids = data.loc[i, 'Span ids']
|
| 74 |
|
| 75 |
+
|
| 76 |
+
yield id, {
|
| 77 |
+
"Content": Content,
|
| 78 |
+
"Span_ids": Span_ids
|
| 79 |
+
}
|
| 80 |
|
| 81 |
# data = pd.read_csv(filepath, colnames=colnames, header = None)
|
| 82 |
# yield data.iloc[:, 0], dataframe.iloc[:, 1], dataframe.iloc[:, 2]
|