kleinay commited on
Commit
5def113
1 Parent(s): 688d120

fix data-reader bugs

Browse files
Files changed (1) hide show
  1. qa_discourse.py +8 -2
qa_discourse.py CHANGED
@@ -52,6 +52,11 @@ _URLs = {
52
  "wikipedia.test": "https://github.com/ValentinaPy/QADiscourse/raw/master/Dataset/wikipedia_test.tsv",
53
  }
54
 
 
 
 
 
 
55
  # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
56
  class QaDiscourse(datasets.GeneratorBasedBuilder):
57
  """QA-Discourse: Discourse Relations as Question-Answer Pairs. """
@@ -133,10 +138,11 @@ class QaDiscourse(datasets.GeneratorBasedBuilder):
133
  """ Yields QA-Discourse examples from a tsv file."""
134
 
135
  # merge annotations from sections
136
- df = pd.concat([pd.read_csv(fn, sep='\t') for fn in filepaths]).reset_index()
 
137
  for counter, row in df.iterrows():
138
  # Prepare question (3 "slots" and question mark)
139
- question = [row.question_start, row.question_aux, row.question_body.str.rstrip('?'), '?']
140
 
141
  yield counter, {
142
  "sentence": row.sentence,
 
52
  "wikipedia.test": "https://github.com/ValentinaPy/QADiscourse/raw/master/Dataset/wikipedia_test.tsv",
53
  }
54
 
55
+ COLUMNS = ['qasrl_id', 'sentence', 'worker_id', 'full_question', 'full_answer',
56
+ 'question_start', 'question_aux', 'question_body', 'answer',
57
+ 'untokenized sentence', 'target indices for untok sent']
58
+
59
+
60
  # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
61
  class QaDiscourse(datasets.GeneratorBasedBuilder):
62
  """QA-Discourse: Discourse Relations as Question-Answer Pairs. """
 
138
  """ Yields QA-Discourse examples from a tsv file."""
139
 
140
  # merge annotations from sections
141
+ df = pd.concat([pd.read_csv(fn, sep='\t', error_bad_lines=False) for fn in filepaths]).reset_index(drop=True)
142
+ df = df.applymap(str) # must turn all values to strings explicitly to avoid type errors
143
  for counter, row in df.iterrows():
144
  # Prepare question (3 "slots" and question mark)
145
+ question = [row.question_start, row.question_aux, row.question_body.rstrip('?'), '?']
146
 
147
  yield counter, {
148
  "sentence": row.sentence,