alexwww94 commited on
Commit
d4d492a
·
1 Parent(s): 5df7013

Update datasets-for-simcse.py

Browse files
Files changed (1) hide show
  1. datasets-for-simcse.py +5 -7
datasets-for-simcse.py CHANGED
@@ -1,8 +1,8 @@
1
  # -*- coding: utf-8 -*-
2
-
3
  import os
4
  import json
5
  import datasets
 
6
 
7
  _DESCRIPTION = """datasets-for-simcse"""
8
 
@@ -55,9 +55,7 @@ class DatasetsForSimCSE(datasets.GeneratorBasedBuilder):
55
 
56
  def _generate_examples(self, filepath):
57
  """This function returns the examples in the raw (text) form."""
58
- with open(filepath, 'r', encoding="utf-8") as f:
59
- f.readline()
60
- for idx, row in enumerate(f.readlines()):
61
- sent0, sent1, hard_neg = row.split(',')
62
- context = {'sent0': sent0, 'sent1': sent1, 'hard_neg': hard_neg}
63
- yield idx, context
 
1
  # -*- coding: utf-8 -*-
 
2
  import os
3
  import json
4
  import datasets
5
+ import pandas as pd
6
 
7
  _DESCRIPTION = """datasets-for-simcse"""
8
 
 
55
 
56
  def _generate_examples(self, filepath):
57
  """This function returns the examples in the raw (text) form."""
58
+ df = pd.read_csv(filepath, sep=',')
59
+ for idx, row in df.iterrows():
60
+ context = {'sent0': row['sent0'], 'sent1': ['sent1'], 'hard_neg': row['hard_neg']}
61
+ yield idx, context