diff --git a/ideas_practice/code/bioasq_extract_yes_no.ipynb b/ideas_practice/code/bioasq_extract_yes_no.ipynb index c71ede48094e2d4d0a73390f20e243b20c455136..d688fc1f2ac96f761073be2e3a38d0dcb52cfa47 100644 --- a/ideas_practice/code/bioasq_extract_yes_no.ipynb +++ b/ideas_practice/code/bioasq_extract_yes_no.ipynb @@ -125,6 +125,7 @@ " writer.writerow(header_tsv)\n", " for question in filtered_data:\n", " id += 1\n", + " written = False\n", " if \"triples\" in question:\n", " for triple in question[\"triples\"]:\n", " # check for the filtering criteria\n", @@ -140,7 +141,12 @@ " relation = base[-1].split(\"#\")[-1] # some of the links include a # for the exact path that needs to be removed\n", " \n", " writer.writerow([question[\"id\"], id, triple[\"s\"], triple[\"p\"], triple[\"o\"], \"\", relation, \"\", \"\", question[\"body\"], question[\"exact_answer\"]])\n", + " written = True\n", " else:\n", + " writer.writerow([question[\"id\"], id, \"\", \"\", \"\", \"\", \"\", \"\", \"\", question[\"body\"], question[\"exact_answer\"]])\n", + " written = True\n", + " # if all triples are filtered the question would not be written without this\n", + " if not written:\n", " writer.writerow([question[\"id\"], id, \"\", \"\", \"\", \"\", \"\", \"\", \"\", question[\"body\"], question[\"exact_answer\"]])" ] },