Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +17 -18
Mimic4Dataset.py
CHANGED
@@ -523,24 +523,23 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
523 |
)
|
524 |
|
525 |
def _generate_examples_text(self, filepath):
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
}
|
544 |
#############################################################################################################################
|
545 |
def _info(self):
|
546 |
self.path = self.init_cohort()
|
|
|
523 |
)
|
524 |
|
525 |
def _generate_examples_text(self, filepath):
|
526 |
+
icd = pd.read_csv('icd10.txt',names=['code','description'],sep='\t')
|
527 |
+
with open(filepath, 'rb') as fp:
|
528 |
+
dico = pickle.load(fp)
|
529 |
+
for key, data in dico.items():
|
530 |
+
conds = data['Cond']['fids']
|
531 |
+
text=[]
|
532 |
+
for code in conds:
|
533 |
+
desc = icd[icd['code']==code]
|
534 |
+
if not desc.empty:
|
535 |
+
text.append(desc['description'].to_string(index=False))
|
536 |
+
template = 'The patient is diagnosed with {}.'
|
537 |
+
text = template.format('; '.join(text))
|
538 |
+
|
539 |
+
yield int(key),{
|
540 |
+
'label' : data['label'],
|
541 |
+
'COND': text,
|
542 |
+
}
|
|
|
543 |
#############################################################################################################################
|
544 |
def _info(self):
|
545 |
self.path = self.init_cohort()
|