phusroyal commited on
Commit
1d8a000
1 Parent(s): b6ba4e6

Update ViHOS.py

Browse files
Files changed (1) hide show
  1. ViHOS.py +14 -10
ViHOS.py CHANGED
@@ -1,6 +1,6 @@
1
  """ViHOS - Vietnamese Hate and Offensive Spans dataset"""
2
 
3
- from csv import reader
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": "train",
48
  },
49
  )
50
  ]
@@ -63,16 +63,20 @@ class ViHOS(datasets.GeneratorBasedBuilder):
63
  return data
64
 
65
  def _generate_examples(self, filepath, split):
66
- # colnames=['id', 'Content', 'Span ids']
 
67
  with open(filepath, 'r', encoding="utf-8") as f:
68
- print(f)
69
- data = self.load_csv(f)
70
- yield data
 
 
71
 
72
- # with open(filepath, 'r', encoding="utf-8") as f:
73
- # for i, line in enumerate(f):
74
- # data = pd.read_csv(f, names=colnames, header = None)
75
- # yield i, data
 
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]