From 4c0567addc163471319cf466d0d70bfae2ded8fd Mon Sep 17 00:00:00 2001
From: Adrien Klose <ikenex3@gmail.com>
Date: Thu, 30 May 2024 12:51:19 +0200
Subject: [PATCH] fix bug that lead to missing questions in the filtering

---
 ideas_practice/code/bioasq_extract_yes_no.ipynb | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ideas_practice/code/bioasq_extract_yes_no.ipynb b/ideas_practice/code/bioasq_extract_yes_no.ipynb
index c71ede4..d688fc1 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\"]])"
    ]
   },
-- 
GitLab