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

Aligning "no-QA sentences" denotation to QANom - records for sentences with no QAs would have both 'question' and 'answers' as empty lists

Browse files
Files changed (1) hide show
  1. qa_discourse.py +10 -3
qa_discourse.py CHANGED
@@ -61,7 +61,7 @@ COLUMNS = ['qasrl_id', 'sentence', 'worker_id', 'full_question', 'full_answer',
61
  class QaDiscourse(datasets.GeneratorBasedBuilder):
62
  """QA-Discourse: Discourse Relations as Question-Answer Pairs. """
63
 
64
- VERSION = datasets.Version("1.0.1")
65
 
66
  BUILDER_CONFIGS = [
67
  datasets.BuilderConfig(
@@ -135,7 +135,10 @@ class QaDiscourse(datasets.GeneratorBasedBuilder):
135
 
136
  def _generate_examples(self, filepaths: List[str]):
137
 
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)
@@ -143,10 +146,14 @@ class QaDiscourse(datasets.GeneratorBasedBuilder):
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,
149
  "sent_id": row.qasrl_id,
150
  "question": question,
151
- "answers": [row.answer],
152
  }
61
  class QaDiscourse(datasets.GeneratorBasedBuilder):
62
  """QA-Discourse: Discourse Relations as Question-Answer Pairs. """
63
 
64
+ VERSION = datasets.Version("1.0.2")
65
 
66
  BUILDER_CONFIGS = [
67
  datasets.BuilderConfig(
135
 
136
  def _generate_examples(self, filepaths: List[str]):
137
 
138
+ """
139
+ Yields QA-Discourse examples from a tsv file.
140
+ Sentences with no QAs will yield an ``empty QA'' record, where both 'question' and 'answers' are empty lists.
141
+ """
142
 
143
  # merge annotations from sections
144
  df = pd.concat([pd.read_csv(fn, sep='\t', error_bad_lines=False) for fn in filepaths]).reset_index(drop=True)
146
  for counter, row in df.iterrows():
147
  # Prepare question (3 "slots" and question mark)
148
  question = [row.question_start, row.question_aux, row.question_body.rstrip('?'), '?']
149
+ answer = [row.answer]
150
+ if row.question_start == "_": # sentence has no QAs
151
+ question = []
152
+ answer = []
153
 
154
  yield counter, {
155
  "sentence": row.sentence,
156
  "sent_id": row.qasrl_id,
157
  "question": question,
158
+ "answers": answer,
159
  }