Switch to unified view

a b/notebooks/13_predictions.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 1,
6
   "id": "36f07a16",
7
   "metadata": {},
8
   "outputs": [
9
    {
10
     "name": "stderr",
11
     "output_type": "stream",
12
     "text": [
13
      "[nltk_data] Error loading punkt: <urlopen error [SSL:\n",
14
      "[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:\n",
15
      "[nltk_data]     unable to get local issuer certificate (_ssl.c:1131)>\n",
16
      "[nltk_data] Error loading stopwords: <urlopen error [SSL:\n",
17
      "[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:\n",
18
      "[nltk_data]     unable to get local issuer certificate (_ssl.c:1131)>\n"
19
     ]
20
    }
21
   ],
22
   "source": [
23
    "import sys\n",
24
    "sys.path.append('../scripts')\n",
25
    "from predict import NER"
26
   ]
27
  },
28
  {
29
   "cell_type": "code",
30
   "execution_count": 2,
31
   "id": "0343fbb3",
32
   "metadata": {},
33
   "outputs": [
34
    {
35
     "name": "stdout",
36
     "output_type": "stream",
37
     "text": [
38
      "Model provided:  Bidirectional LSTM Model with single LSTM layer\n"
39
     ]
40
    },
41
    {
42
     "name": "stderr",
43
     "output_type": "stream",
44
     "text": [
45
      "2023-04-10 10:34:04.285190: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz\n"
46
     ]
47
    },
48
    {
49
     "name": "stdout",
50
     "output_type": "stream",
51
     "text": [
52
      "1/1 [==============================] - 0s 422ms/step\n",
53
      "Predicted Named Entities:\n",
54
      "57: Age\n",
55
      "year: Age\n",
56
      "old: Age\n",
57
      "man: Sex\n",
58
      "presented: Nonbiological_location\n",
59
      "emergency: Nonbiological_location\n",
60
      "department: Duration\n",
61
      "2: Duration\n",
62
      "day: O\n",
63
      "history: Sign_symptom\n",
64
      "worsening: Sign_symptom\n",
65
      "shortness: Biological_structure\n",
66
      "breath: Sign_symptom\n",
67
      "chest: History\n",
68
      "pain: History\n",
69
      "reported: History\n",
70
      "recent: History\n",
71
      "travel: History\n",
72
      "sick: History\n",
73
      "contacts: History\n",
74
      "medical: History\n",
75
      "history: History\n",
76
      "significant: History\n",
77
      "hypertension: History\n",
78
      "dyslipidemia: History\n",
79
      "type: History\n",
80
      "2: Sign_symptom\n",
81
      "diabetes: History\n",
82
      "mellitus: Diagnostic_procedure\n",
83
      "examination: O\n",
84
      "tachycardic: Detailed_description\n",
85
      "tachypneic: Detailed_description\n",
86
      "oxygen: Biological_structure\n",
87
      "saturation: Diagnostic_procedure\n",
88
      "88: Detailed_description\n",
89
      "room: O\n",
90
      "air: Distance\n",
91
      "chest: Distance\n",
92
      "radiography: O\n",
93
      "revealed: Distance\n",
94
      "bilateral: O\n",
95
      "opacities: O\n",
96
      "consistent: O\n",
97
      "pulmonary: Detailed_description\n",
98
      "edema: Distance\n",
99
      "patient: Distance\n",
100
      "admitted: Distance\n",
101
      "intensive: Medication\n",
102
      "care: Therapeutic_procedure\n",
103
      "unit: Medication\n",
104
      "management: Dosage\n",
105
      "acute: Dosage\n",
106
      "decompensated: Dosage\n",
107
      "heart: Clinical_event\n",
108
      "failure: Other_entity\n",
109
      "started: Nonbiological_location\n",
110
      "intravenous: Date\n",
111
      "diuretics: Date\n",
112
      "inotropic: O\n",
113
      "support: O\n",
114
      "dobutamine: O\n",
115
      "next: O\n",
116
      "several: O\n",
117
      "days: O\n",
118
      "symptoms: O\n",
119
      "improved: O\n",
120
      "discharged: O\n",
121
      "home: O\n",
122
      "instructions: O\n",
123
      "follow: O\n",
124
      "primary: O\n",
125
      "care: O\n",
126
      "provider: O\n",
127
      "1: O\n",
128
      "week: O\n"
129
     ]
130
    },
131
    {
132
     "data": {
133
      "text/html": [
134
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
135
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
136
       "    57\n",
137
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
138
       "</mark>\n",
139
       "-\n",
140
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
141
       "    year\n",
142
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
143
       "</mark>\n",
144
       "-\n",
145
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
146
       "    old\n",
147
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
148
       "</mark>\n",
149
       " \n",
150
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
151
       "    man\n",
152
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
153
       "</mark>\n",
154
       " \n",
155
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
156
       "    presented\n",
157
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
158
       "</mark>\n",
159
       " to the \n",
160
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
161
       "    emergency\n",
162
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
163
       "</mark>\n",
164
       " \n",
165
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
166
       "    department\n",
167
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
168
       "</mark>\n",
169
       " with a \n",
170
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
171
       "    2\n",
172
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
173
       "</mark>\n",
174
       "-day \n",
175
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
176
       "    history\n",
177
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
178
       "</mark>\n",
179
       " of \n",
180
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
181
       "    worsening\n",
182
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
183
       "</mark>\n",
184
       " \n",
185
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
186
       "    shortness\n",
187
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
188
       "</mark>\n",
189
       " of \n",
190
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
191
       "    breath\n",
192
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
193
       "</mark>\n",
194
       " and \n",
195
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
196
       "    chest\n",
197
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
198
       "</mark>\n",
199
       " \n",
200
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
201
       "    pain\n",
202
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
203
       "</mark>\n",
204
       ". He \n",
205
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
206
       "    reported\n",
207
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
208
       "</mark>\n",
209
       " no \n",
210
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
211
       "    recent\n",
212
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
213
       "</mark>\n",
214
       " \n",
215
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
216
       "    travel\n",
217
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
218
       "</mark>\n",
219
       " or \n",
220
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
221
       "    sick\n",
222
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
223
       "</mark>\n",
224
       " \n",
225
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
226
       "    contacts\n",
227
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
228
       "</mark>\n",
229
       ". His \n",
230
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
231
       "    medical\n",
232
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
233
       "</mark>\n",
234
       " \n",
235
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
236
       "    history\n",
237
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
238
       "</mark>\n",
239
       " was \n",
240
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
241
       "    significant\n",
242
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
243
       "</mark>\n",
244
       " for \n",
245
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
246
       "    hypertension\n",
247
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
248
       "</mark>\n",
249
       ", \n",
250
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
251
       "    dyslipidemia\n",
252
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
253
       "</mark>\n",
254
       ", and \n",
255
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
256
       "    type\n",
257
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
258
       "</mark>\n",
259
       " \n",
260
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
261
       "    2\n",
262
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
263
       "</mark>\n",
264
       " \n",
265
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
266
       "    diabetes\n",
267
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
268
       "</mark>\n",
269
       " \n",
270
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
271
       "    mellitus\n",
272
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
273
       "</mark>\n",
274
       ". On examination, he was \n",
275
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
276
       "    tachycardic\n",
277
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
278
       "</mark>\n",
279
       " and \n",
280
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
281
       "    tachypneic\n",
282
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
283
       "</mark>\n",
284
       ", with \n",
285
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
286
       "    oxygen\n",
287
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
288
       "</mark>\n",
289
       " \n",
290
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
291
       "    saturation\n",
292
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
293
       "</mark>\n",
294
       " of \n",
295
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
296
       "    88\n",
297
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
298
       "</mark>\n",
299
       "% on room \n",
300
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
301
       "    air\n",
302
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
303
       "</mark>\n",
304
       ". \n",
305
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
306
       "    Chest\n",
307
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
308
       "</mark>\n",
309
       " radiography \n",
310
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
311
       "    revealed\n",
312
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
313
       "</mark>\n",
314
       " bilateral opacities consistent with \n",
315
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
316
       "    pulmonary\n",
317
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
318
       "</mark>\n",
319
       " \n",
320
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
321
       "    edema\n",
322
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
323
       "</mark>\n",
324
       ". The \n",
325
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
326
       "    patient\n",
327
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
328
       "</mark>\n",
329
       " was \n",
330
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
331
       "    admitted\n",
332
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
333
       "</mark>\n",
334
       " to the \n",
335
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
336
       "    intensive\n",
337
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
338
       "</mark>\n",
339
       " \n",
340
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
341
       "    care\n",
342
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
343
       "</mark>\n",
344
       " \n",
345
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
346
       "    unit\n",
347
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
348
       "</mark>\n",
349
       " for \n",
350
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
351
       "    management\n",
352
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
353
       "</mark>\n",
354
       " of \n",
355
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
356
       "    acute\n",
357
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
358
       "</mark>\n",
359
       " \n",
360
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
361
       "    decompensated\n",
362
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
363
       "</mark>\n",
364
       " \n",
365
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
366
       "    heart\n",
367
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
368
       "</mark>\n",
369
       " \n",
370
       "<mark class=\"entity\" style=\"background: #d5f5e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
371
       "    failure\n",
372
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Other_entity</span>\n",
373
       "</mark>\n",
374
       ". He was \n",
375
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
376
       "    started\n",
377
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
378
       "</mark>\n",
379
       " on \n",
380
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
381
       "    intravenous\n",
382
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
383
       "</mark>\n",
384
       " \n",
385
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
386
       "    diuretics\n",
387
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
388
       "</mark>\n",
389
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
390
      ],
391
      "text/plain": [
392
       "<IPython.core.display.HTML object>"
393
      ]
394
     },
395
     "metadata": {},
396
     "output_type": "display_data"
397
    }
398
   ],
399
   "source": [
400
    "NER(\"model_1\",\n",
401
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
402
   ]
403
  },
404
  {
405
   "cell_type": "markdown",
406
   "id": "d8b3b880",
407
   "metadata": {},
408
   "source": [
409
    "## MODEL 2"
410
   ]
411
  },
412
  {
413
   "cell_type": "code",
414
   "execution_count": 3,
415
   "id": "27ca7748",
416
   "metadata": {},
417
   "outputs": [
418
    {
419
     "name": "stdout",
420
     "output_type": "stream",
421
     "text": [
422
      "Model provided:  Bidirectional LSTM Model with two LSTM layers and one Hidden Dense Layer\n",
423
      "1/1 [==============================] - 1s 651ms/step\n",
424
      "Predicted Named Entities:\n",
425
      "57: Age\n",
426
      "year: Age\n",
427
      "old: Age\n",
428
      "man: Sex\n",
429
      "presented: Nonbiological_location\n",
430
      "emergency: Nonbiological_location\n",
431
      "department: History\n",
432
      "2: Date\n",
433
      "day: O\n",
434
      "history: Sign_symptom\n",
435
      "worsening: Sign_symptom\n",
436
      "shortness: Biological_structure\n",
437
      "breath: Sign_symptom\n",
438
      "chest: O\n",
439
      "pain: Nonbiological_location\n",
440
      "reported: History\n",
441
      "recent: History\n",
442
      "travel: History\n",
443
      "sick: History\n",
444
      "contacts: History\n",
445
      "medical: Nonbiological_location\n",
446
      "history: Nonbiological_location\n",
447
      "significant: History\n",
448
      "hypertension: Nonbiological_location\n",
449
      "dyslipidemia: Nonbiological_location\n",
450
      "type: Nonbiological_location\n",
451
      "2: Biological_structure\n",
452
      "diabetes: Diagnostic_procedure\n",
453
      "mellitus: Diagnostic_procedure\n",
454
      "examination: Lab_value\n",
455
      "tachycardic: Detailed_description\n",
456
      "tachypneic: Detailed_description\n",
457
      "oxygen: Biological_structure\n",
458
      "saturation: Diagnostic_procedure\n",
459
      "88: Detailed_description\n",
460
      "room: O\n",
461
      "air: Biological_structure\n",
462
      "chest: Sign_symptom\n",
463
      "radiography: O\n",
464
      "revealed: Biological_structure\n",
465
      "bilateral: Biological_structure\n",
466
      "opacities: Biological_structure\n",
467
      "consistent: O\n",
468
      "pulmonary: Detailed_description\n",
469
      "edema: Distance\n",
470
      "patient: Therapeutic_procedure\n",
471
      "admitted: Medication\n",
472
      "intensive: Medication\n",
473
      "care: Medication\n",
474
      "unit: Medication\n",
475
      "management: Dosage\n",
476
      "acute: Dosage\n",
477
      "decompensated: History\n",
478
      "heart: Date\n",
479
      "failure: Nonbiological_location\n",
480
      "started: History\n",
481
      "intravenous: History\n",
482
      "diuretics: Duration\n",
483
      "inotropic: O\n",
484
      "support: O\n",
485
      "dobutamine: O\n",
486
      "next: O\n",
487
      "several: O\n",
488
      "days: O\n",
489
      "symptoms: O\n",
490
      "improved: O\n",
491
      "discharged: O\n",
492
      "home: O\n",
493
      "instructions: O\n",
494
      "follow: O\n",
495
      "primary: O\n",
496
      "care: O\n",
497
      "provider: O\n",
498
      "1: O\n",
499
      "week: O\n"
500
     ]
501
    },
502
    {
503
     "data": {
504
      "text/html": [
505
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
506
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
507
       "    57\n",
508
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
509
       "</mark>\n",
510
       "-\n",
511
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
512
       "    year\n",
513
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
514
       "</mark>\n",
515
       "-\n",
516
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
517
       "    old\n",
518
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
519
       "</mark>\n",
520
       " \n",
521
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
522
       "    man\n",
523
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
524
       "</mark>\n",
525
       " \n",
526
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
527
       "    presented\n",
528
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
529
       "</mark>\n",
530
       " to the \n",
531
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
532
       "    emergency\n",
533
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
534
       "</mark>\n",
535
       " \n",
536
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
537
       "    department\n",
538
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
539
       "</mark>\n",
540
       " with a \n",
541
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
542
       "    2\n",
543
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
544
       "</mark>\n",
545
       "-day \n",
546
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
547
       "    history\n",
548
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
549
       "</mark>\n",
550
       " of \n",
551
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
552
       "    worsening\n",
553
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
554
       "</mark>\n",
555
       " \n",
556
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
557
       "    shortness\n",
558
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
559
       "</mark>\n",
560
       " of \n",
561
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
562
       "    breath\n",
563
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
564
       "</mark>\n",
565
       " and chest \n",
566
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
567
       "    pain\n",
568
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
569
       "</mark>\n",
570
       ". He \n",
571
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
572
       "    reported\n",
573
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
574
       "</mark>\n",
575
       " no \n",
576
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
577
       "    recent\n",
578
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
579
       "</mark>\n",
580
       " \n",
581
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
582
       "    travel\n",
583
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
584
       "</mark>\n",
585
       " or \n",
586
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
587
       "    sick\n",
588
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
589
       "</mark>\n",
590
       " \n",
591
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
592
       "    contacts\n",
593
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
594
       "</mark>\n",
595
       ". His \n",
596
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
597
       "    medical\n",
598
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
599
       "</mark>\n",
600
       " \n",
601
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
602
       "    history\n",
603
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
604
       "</mark>\n",
605
       " was \n",
606
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
607
       "    significant\n",
608
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
609
       "</mark>\n",
610
       " for \n",
611
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
612
       "    hypertension\n",
613
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
614
       "</mark>\n",
615
       ", \n",
616
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
617
       "    dyslipidemia\n",
618
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
619
       "</mark>\n",
620
       ", and \n",
621
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
622
       "    type\n",
623
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
624
       "</mark>\n",
625
       " \n",
626
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
627
       "    2\n",
628
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
629
       "</mark>\n",
630
       " \n",
631
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
632
       "    diabetes\n",
633
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
634
       "</mark>\n",
635
       " \n",
636
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
637
       "    mellitus\n",
638
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
639
       "</mark>\n",
640
       ". On \n",
641
       "<mark class=\"entity\" style=\"background: #f4b3c2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
642
       "    examination\n",
643
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Lab_value</span>\n",
644
       "</mark>\n",
645
       ", he was \n",
646
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
647
       "    tachycardic\n",
648
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
649
       "</mark>\n",
650
       " and \n",
651
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
652
       "    tachypneic\n",
653
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
654
       "</mark>\n",
655
       ", with \n",
656
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
657
       "    oxygen\n",
658
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
659
       "</mark>\n",
660
       " \n",
661
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
662
       "    saturation\n",
663
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
664
       "</mark>\n",
665
       " of \n",
666
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
667
       "    88\n",
668
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
669
       "</mark>\n",
670
       "% on room \n",
671
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
672
       "    air\n",
673
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
674
       "</mark>\n",
675
       ". \n",
676
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
677
       "    Chest\n",
678
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
679
       "</mark>\n",
680
       " radiography \n",
681
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
682
       "    revealed\n",
683
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
684
       "</mark>\n",
685
       " \n",
686
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
687
       "    bilateral\n",
688
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
689
       "</mark>\n",
690
       " \n",
691
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
692
       "    opacities\n",
693
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
694
       "</mark>\n",
695
       " consistent with \n",
696
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
697
       "    pulmonary\n",
698
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
699
       "</mark>\n",
700
       " \n",
701
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
702
       "    edema\n",
703
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
704
       "</mark>\n",
705
       ". The \n",
706
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
707
       "    patient\n",
708
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
709
       "</mark>\n",
710
       " was \n",
711
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
712
       "    admitted\n",
713
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
714
       "</mark>\n",
715
       " to the \n",
716
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
717
       "    intensive\n",
718
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
719
       "</mark>\n",
720
       " \n",
721
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
722
       "    care\n",
723
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
724
       "</mark>\n",
725
       " \n",
726
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
727
       "    unit\n",
728
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
729
       "</mark>\n",
730
       " for \n",
731
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
732
       "    management\n",
733
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
734
       "</mark>\n",
735
       " of \n",
736
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
737
       "    acute\n",
738
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
739
       "</mark>\n",
740
       " \n",
741
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
742
       "    decompensated\n",
743
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
744
       "</mark>\n",
745
       " \n",
746
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
747
       "    heart\n",
748
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
749
       "</mark>\n",
750
       " \n",
751
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
752
       "    failure\n",
753
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
754
       "</mark>\n",
755
       ". He was \n",
756
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
757
       "    started\n",
758
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
759
       "</mark>\n",
760
       " on \n",
761
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
762
       "    intravenous\n",
763
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
764
       "</mark>\n",
765
       " \n",
766
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
767
       "    diuretics\n",
768
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
769
       "</mark>\n",
770
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
771
      ],
772
      "text/plain": [
773
       "<IPython.core.display.HTML object>"
774
      ]
775
     },
776
     "metadata": {},
777
     "output_type": "display_data"
778
    }
779
   ],
780
   "source": [
781
    "NER(\"model_2\",\n",
782
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
783
   ]
784
  },
785
  {
786
   "cell_type": "markdown",
787
   "id": "d0f9b03d",
788
   "metadata": {},
789
   "source": [
790
    "## MODEL 3"
791
   ]
792
  },
793
  {
794
   "cell_type": "code",
795
   "execution_count": 4,
796
   "id": "e3fb5de6",
797
   "metadata": {},
798
   "outputs": [
799
    {
800
     "name": "stdout",
801
     "output_type": "stream",
802
     "text": [
803
      "Model provided:  Bidirectional LSTM model with BioWordVecEmbedding Layers followed two LSTM layers and one Hidden Dense Layer\n",
804
      "1/1 [==============================] - 1s 616ms/step\n",
805
      "Predicted Named Entities:\n",
806
      "57: Age\n",
807
      "year: Age\n",
808
      "old: Age\n",
809
      "man: Sex\n",
810
      "presented: Nonbiological_location\n",
811
      "emergency: Nonbiological_location\n",
812
      "department: Date\n",
813
      "2: Duration\n",
814
      "day: O\n",
815
      "history: Sign_symptom\n",
816
      "worsening: Sign_symptom\n",
817
      "shortness: Biological_structure\n",
818
      "breath: Sign_symptom\n",
819
      "chest: O\n",
820
      "pain: History\n",
821
      "reported: History\n",
822
      "recent: History\n",
823
      "travel: O\n",
824
      "sick: History\n",
825
      "contacts: History\n",
826
      "medical: History\n",
827
      "history: History\n",
828
      "significant: History\n",
829
      "hypertension: History\n",
830
      "dyslipidemia: History\n",
831
      "type: O\n",
832
      "2: Sign_symptom\n",
833
      "diabetes: Diagnostic_procedure\n",
834
      "mellitus: Diagnostic_procedure\n",
835
      "examination: Date\n",
836
      "tachycardic: History\n",
837
      "tachypneic: Detailed_description\n",
838
      "oxygen: Biological_structure\n",
839
      "saturation: Diagnostic_procedure\n",
840
      "88: Detailed_description\n",
841
      "room: O\n",
842
      "air: Distance\n",
843
      "chest: Sign_symptom\n",
844
      "radiography: O\n",
845
      "revealed: Nonbiological_location\n",
846
      "bilateral: Nonbiological_location\n",
847
      "opacities: Nonbiological_location\n",
848
      "consistent: O\n",
849
      "pulmonary: Detailed_description\n",
850
      "edema: Distance\n",
851
      "patient: Distance\n",
852
      "admitted: Administration\n",
853
      "intensive: Medication\n",
854
      "care: Medication\n",
855
      "unit: Medication\n",
856
      "management: O\n",
857
      "acute: Clinical_event\n",
858
      "decompensated: Nonbiological_location\n",
859
      "heart: Clinical_event\n",
860
      "failure: Nonbiological_location\n",
861
      "started: Nonbiological_location\n",
862
      "intravenous: Date\n",
863
      "diuretics: Duration\n",
864
      "inotropic: O\n",
865
      "support: O\n",
866
      "dobutamine: O\n",
867
      "next: O\n",
868
      "several: O\n",
869
      "days: O\n",
870
      "symptoms: O\n",
871
      "improved: O\n",
872
      "discharged: O\n",
873
      "home: O\n",
874
      "instructions: O\n",
875
      "follow: O\n",
876
      "primary: O\n",
877
      "care: O\n",
878
      "provider: O\n",
879
      "1: O\n",
880
      "week: O\n"
881
     ]
882
    },
883
    {
884
     "data": {
885
      "text/html": [
886
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
887
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
888
       "    57\n",
889
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
890
       "</mark>\n",
891
       "-\n",
892
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
893
       "    year\n",
894
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
895
       "</mark>\n",
896
       "-\n",
897
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
898
       "    old\n",
899
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
900
       "</mark>\n",
901
       " \n",
902
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
903
       "    man\n",
904
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
905
       "</mark>\n",
906
       " \n",
907
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
908
       "    presented\n",
909
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
910
       "</mark>\n",
911
       " to the \n",
912
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
913
       "    emergency\n",
914
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
915
       "</mark>\n",
916
       " \n",
917
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
918
       "    department\n",
919
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
920
       "</mark>\n",
921
       " with a \n",
922
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
923
       "    2\n",
924
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
925
       "</mark>\n",
926
       "-day \n",
927
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
928
       "    history\n",
929
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
930
       "</mark>\n",
931
       " of \n",
932
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
933
       "    worsening\n",
934
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
935
       "</mark>\n",
936
       " \n",
937
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
938
       "    shortness\n",
939
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
940
       "</mark>\n",
941
       " of \n",
942
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
943
       "    breath\n",
944
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
945
       "</mark>\n",
946
       " and chest \n",
947
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
948
       "    pain\n",
949
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
950
       "</mark>\n",
951
       ". He \n",
952
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
953
       "    reported\n",
954
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
955
       "</mark>\n",
956
       " no \n",
957
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
958
       "    recent\n",
959
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
960
       "</mark>\n",
961
       " travel or \n",
962
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
963
       "    sick\n",
964
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
965
       "</mark>\n",
966
       " \n",
967
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
968
       "    contacts\n",
969
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
970
       "</mark>\n",
971
       ". His \n",
972
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
973
       "    medical\n",
974
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
975
       "</mark>\n",
976
       " \n",
977
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
978
       "    history\n",
979
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
980
       "</mark>\n",
981
       " was \n",
982
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
983
       "    significant\n",
984
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
985
       "</mark>\n",
986
       " for \n",
987
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
988
       "    hypertension\n",
989
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
990
       "</mark>\n",
991
       ", \n",
992
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
993
       "    dyslipidemia\n",
994
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
995
       "</mark>\n",
996
       ", and type \n",
997
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
998
       "    2\n",
999
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1000
       "</mark>\n",
1001
       " \n",
1002
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1003
       "    diabetes\n",
1004
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1005
       "</mark>\n",
1006
       " \n",
1007
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1008
       "    mellitus\n",
1009
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1010
       "</mark>\n",
1011
       ". On \n",
1012
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1013
       "    examination\n",
1014
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
1015
       "</mark>\n",
1016
       ", he was \n",
1017
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1018
       "    tachycardic\n",
1019
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1020
       "</mark>\n",
1021
       " and \n",
1022
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1023
       "    tachypneic\n",
1024
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1025
       "</mark>\n",
1026
       ", with \n",
1027
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1028
       "    oxygen\n",
1029
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1030
       "</mark>\n",
1031
       " \n",
1032
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1033
       "    saturation\n",
1034
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1035
       "</mark>\n",
1036
       " of \n",
1037
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1038
       "    88\n",
1039
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1040
       "</mark>\n",
1041
       "% on room \n",
1042
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1043
       "    air\n",
1044
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
1045
       "</mark>\n",
1046
       ". \n",
1047
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1048
       "    Chest\n",
1049
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1050
       "</mark>\n",
1051
       " radiography \n",
1052
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1053
       "    revealed\n",
1054
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1055
       "</mark>\n",
1056
       " \n",
1057
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1058
       "    bilateral\n",
1059
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1060
       "</mark>\n",
1061
       " \n",
1062
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1063
       "    opacities\n",
1064
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1065
       "</mark>\n",
1066
       " consistent with \n",
1067
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1068
       "    pulmonary\n",
1069
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1070
       "</mark>\n",
1071
       " \n",
1072
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1073
       "    edema\n",
1074
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
1075
       "</mark>\n",
1076
       ". The \n",
1077
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1078
       "    patient\n",
1079
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
1080
       "</mark>\n",
1081
       " was \n",
1082
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1083
       "    admitted\n",
1084
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Administration</span>\n",
1085
       "</mark>\n",
1086
       " to the \n",
1087
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1088
       "    intensive\n",
1089
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1090
       "</mark>\n",
1091
       " \n",
1092
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1093
       "    care\n",
1094
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1095
       "</mark>\n",
1096
       " \n",
1097
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1098
       "    unit\n",
1099
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1100
       "</mark>\n",
1101
       " for management of \n",
1102
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1103
       "    acute\n",
1104
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
1105
       "</mark>\n",
1106
       " \n",
1107
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1108
       "    decompensated\n",
1109
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1110
       "</mark>\n",
1111
       " \n",
1112
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1113
       "    heart\n",
1114
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
1115
       "</mark>\n",
1116
       " \n",
1117
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1118
       "    failure\n",
1119
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1120
       "</mark>\n",
1121
       ". He was \n",
1122
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1123
       "    started\n",
1124
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1125
       "</mark>\n",
1126
       " on \n",
1127
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1128
       "    intravenous\n",
1129
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
1130
       "</mark>\n",
1131
       " \n",
1132
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1133
       "    diuretics\n",
1134
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1135
       "</mark>\n",
1136
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
1137
      ],
1138
      "text/plain": [
1139
       "<IPython.core.display.HTML object>"
1140
      ]
1141
     },
1142
     "metadata": {},
1143
     "output_type": "display_data"
1144
    }
1145
   ],
1146
   "source": [
1147
    "NER(\"model_3\",\n",
1148
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
1149
   ]
1150
  },
1151
  {
1152
   "cell_type": "markdown",
1153
   "id": "839cf967",
1154
   "metadata": {},
1155
   "source": [
1156
    "## MODEL 4"
1157
   ]
1158
  },
1159
  {
1160
   "cell_type": "code",
1161
   "execution_count": 5,
1162
   "id": "16e0a82c",
1163
   "metadata": {},
1164
   "outputs": [
1165
    {
1166
     "name": "stdout",
1167
     "output_type": "stream",
1168
     "text": [
1169
      "Model provided:  Bidirectional LSTM Model with Time Distributed Dense Layers - Single LSTM layer and Two time distributed dense layers\n",
1170
      "1/1 [==============================] - 0s 319ms/step\n",
1171
      "Predicted Named Entities:\n",
1172
      "57: Age\n",
1173
      "year: Age\n",
1174
      "old: Age\n",
1175
      "man: Sex\n",
1176
      "presented: Nonbiological_location\n",
1177
      "emergency: Nonbiological_location\n",
1178
      "department: Date\n",
1179
      "2: Duration\n",
1180
      "day: History\n",
1181
      "history: Sign_symptom\n",
1182
      "worsening: Sign_symptom\n",
1183
      "shortness: Sign_symptom\n",
1184
      "breath: Sign_symptom\n",
1185
      "chest: History\n",
1186
      "pain: History\n",
1187
      "reported: History\n",
1188
      "recent: History\n",
1189
      "travel: History\n",
1190
      "sick: History\n",
1191
      "contacts: History\n",
1192
      "medical: History\n",
1193
      "history: History\n",
1194
      "significant: History\n",
1195
      "hypertension: History\n",
1196
      "dyslipidemia: History\n",
1197
      "type: Diagnostic_procedure\n",
1198
      "2: Biological_structure\n",
1199
      "diabetes: Diagnostic_procedure\n",
1200
      "mellitus: Diagnostic_procedure\n",
1201
      "examination: Lab_value\n",
1202
      "tachycardic: Detailed_description\n",
1203
      "tachypneic: Detailed_description\n",
1204
      "oxygen: Biological_structure\n",
1205
      "saturation: Diagnostic_procedure\n",
1206
      "88: Detailed_description\n",
1207
      "room: O\n",
1208
      "air: Biological_structure\n",
1209
      "chest: O\n",
1210
      "radiography: O\n",
1211
      "revealed: Distance\n",
1212
      "bilateral: Nonbiological_location\n",
1213
      "opacities: Nonbiological_location\n",
1214
      "consistent: O\n",
1215
      "pulmonary: O\n",
1216
      "edema: Medication\n",
1217
      "patient: Medication\n",
1218
      "admitted: Administration\n",
1219
      "intensive: Medication\n",
1220
      "care: Medication\n",
1221
      "unit: Medication\n",
1222
      "management: Dosage\n",
1223
      "acute: Dosage\n",
1224
      "decompensated: Nonbiological_location\n",
1225
      "heart: Clinical_event\n",
1226
      "failure: Medication\n",
1227
      "started: Nonbiological_location\n",
1228
      "intravenous: Date\n",
1229
      "diuretics: Duration\n",
1230
      "inotropic: O\n",
1231
      "support: O\n",
1232
      "dobutamine: O\n",
1233
      "next: O\n",
1234
      "several: O\n",
1235
      "days: O\n",
1236
      "symptoms: O\n",
1237
      "improved: O\n",
1238
      "discharged: O\n",
1239
      "home: O\n",
1240
      "instructions: O\n",
1241
      "follow: O\n",
1242
      "primary: O\n",
1243
      "care: O\n",
1244
      "provider: O\n",
1245
      "1: O\n",
1246
      "week: O\n"
1247
     ]
1248
    },
1249
    {
1250
     "data": {
1251
      "text/html": [
1252
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
1253
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1254
       "    57\n",
1255
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1256
       "</mark>\n",
1257
       "-\n",
1258
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1259
       "    year\n",
1260
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1261
       "</mark>\n",
1262
       "-\n",
1263
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1264
       "    old\n",
1265
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1266
       "</mark>\n",
1267
       " \n",
1268
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1269
       "    man\n",
1270
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
1271
       "</mark>\n",
1272
       " \n",
1273
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1274
       "    presented\n",
1275
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1276
       "</mark>\n",
1277
       " to the \n",
1278
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1279
       "    emergency\n",
1280
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1281
       "</mark>\n",
1282
       " \n",
1283
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1284
       "    department\n",
1285
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
1286
       "</mark>\n",
1287
       " with a \n",
1288
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1289
       "    2\n",
1290
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1291
       "</mark>\n",
1292
       "-\n",
1293
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1294
       "    day\n",
1295
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1296
       "</mark>\n",
1297
       " \n",
1298
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1299
       "    history\n",
1300
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1301
       "</mark>\n",
1302
       " of \n",
1303
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1304
       "    worsening\n",
1305
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1306
       "</mark>\n",
1307
       " \n",
1308
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1309
       "    shortness\n",
1310
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1311
       "</mark>\n",
1312
       " of \n",
1313
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1314
       "    breath\n",
1315
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1316
       "</mark>\n",
1317
       " and \n",
1318
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1319
       "    chest\n",
1320
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1321
       "</mark>\n",
1322
       " \n",
1323
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1324
       "    pain\n",
1325
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1326
       "</mark>\n",
1327
       ". He \n",
1328
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1329
       "    reported\n",
1330
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1331
       "</mark>\n",
1332
       " no \n",
1333
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1334
       "    recent\n",
1335
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1336
       "</mark>\n",
1337
       " \n",
1338
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1339
       "    travel\n",
1340
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1341
       "</mark>\n",
1342
       " or \n",
1343
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1344
       "    sick\n",
1345
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1346
       "</mark>\n",
1347
       " \n",
1348
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1349
       "    contacts\n",
1350
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1351
       "</mark>\n",
1352
       ". His \n",
1353
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1354
       "    medical\n",
1355
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1356
       "</mark>\n",
1357
       " \n",
1358
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1359
       "    history\n",
1360
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1361
       "</mark>\n",
1362
       " was \n",
1363
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1364
       "    significant\n",
1365
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1366
       "</mark>\n",
1367
       " for \n",
1368
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1369
       "    hypertension\n",
1370
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1371
       "</mark>\n",
1372
       ", \n",
1373
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1374
       "    dyslipidemia\n",
1375
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1376
       "</mark>\n",
1377
       ", and \n",
1378
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1379
       "    type\n",
1380
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1381
       "</mark>\n",
1382
       " \n",
1383
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1384
       "    2\n",
1385
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1386
       "</mark>\n",
1387
       " \n",
1388
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1389
       "    diabetes\n",
1390
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1391
       "</mark>\n",
1392
       " \n",
1393
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1394
       "    mellitus\n",
1395
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1396
       "</mark>\n",
1397
       ". On \n",
1398
       "<mark class=\"entity\" style=\"background: #f4b3c2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1399
       "    examination\n",
1400
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Lab_value</span>\n",
1401
       "</mark>\n",
1402
       ", he was \n",
1403
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1404
       "    tachycardic\n",
1405
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1406
       "</mark>\n",
1407
       " and \n",
1408
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1409
       "    tachypneic\n",
1410
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1411
       "</mark>\n",
1412
       ", with \n",
1413
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1414
       "    oxygen\n",
1415
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1416
       "</mark>\n",
1417
       " \n",
1418
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1419
       "    saturation\n",
1420
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1421
       "</mark>\n",
1422
       " of \n",
1423
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1424
       "    88\n",
1425
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1426
       "</mark>\n",
1427
       "% on room \n",
1428
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1429
       "    air\n",
1430
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1431
       "</mark>\n",
1432
       ". Chest radiography \n",
1433
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1434
       "    revealed\n",
1435
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
1436
       "</mark>\n",
1437
       " \n",
1438
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1439
       "    bilateral\n",
1440
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1441
       "</mark>\n",
1442
       " \n",
1443
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1444
       "    opacities\n",
1445
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1446
       "</mark>\n",
1447
       " consistent with pulmonary \n",
1448
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1449
       "    edema\n",
1450
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1451
       "</mark>\n",
1452
       ". The \n",
1453
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1454
       "    patient\n",
1455
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1456
       "</mark>\n",
1457
       " was \n",
1458
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1459
       "    admitted\n",
1460
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Administration</span>\n",
1461
       "</mark>\n",
1462
       " to the \n",
1463
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1464
       "    intensive\n",
1465
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1466
       "</mark>\n",
1467
       " \n",
1468
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1469
       "    care\n",
1470
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1471
       "</mark>\n",
1472
       " \n",
1473
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1474
       "    unit\n",
1475
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1476
       "</mark>\n",
1477
       " for \n",
1478
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1479
       "    management\n",
1480
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
1481
       "</mark>\n",
1482
       " of \n",
1483
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1484
       "    acute\n",
1485
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
1486
       "</mark>\n",
1487
       " \n",
1488
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1489
       "    decompensated\n",
1490
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1491
       "</mark>\n",
1492
       " \n",
1493
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1494
       "    heart\n",
1495
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
1496
       "</mark>\n",
1497
       " \n",
1498
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1499
       "    failure\n",
1500
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1501
       "</mark>\n",
1502
       ". He was \n",
1503
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1504
       "    started\n",
1505
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1506
       "</mark>\n",
1507
       " on \n",
1508
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1509
       "    intravenous\n",
1510
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
1511
       "</mark>\n",
1512
       " \n",
1513
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1514
       "    diuretics\n",
1515
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1516
       "</mark>\n",
1517
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
1518
      ],
1519
      "text/plain": [
1520
       "<IPython.core.display.HTML object>"
1521
      ]
1522
     },
1523
     "metadata": {},
1524
     "output_type": "display_data"
1525
    }
1526
   ],
1527
   "source": [
1528
    "NER(\"model_4\",\n",
1529
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
1530
   ]
1531
  },
1532
  {
1533
   "cell_type": "markdown",
1534
   "id": "d4bf4681",
1535
   "metadata": {},
1536
   "source": [
1537
    "## MODEL 5"
1538
   ]
1539
  },
1540
  {
1541
   "cell_type": "code",
1542
   "execution_count": 6,
1543
   "id": "b5c6fa06",
1544
   "metadata": {
1545
    "scrolled": false
1546
   },
1547
   "outputs": [
1548
    {
1549
     "name": "stdout",
1550
     "output_type": "stream",
1551
     "text": [
1552
      "Model provided:  Bidirectional LSTM Model with two LSTM layers and one Hidden Dense Layer\n",
1553
      "WARNING:tensorflow:5 out of the last 5 calls to <function Model.make_predict_function.<locals>.predict_function at 0x2eb898310> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has reduce_retracing=True option that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.\n",
1554
      "1/1 [==============================] - 0s 337ms/step\n",
1555
      "Predicted Named Entities:\n",
1556
      "57: Age\n",
1557
      "year: Age\n",
1558
      "old: Age\n",
1559
      "man: Sex\n",
1560
      "presented: Nonbiological_location\n",
1561
      "emergency: Nonbiological_location\n",
1562
      "department: Duration\n",
1563
      "2: Duration\n",
1564
      "day: O\n",
1565
      "history: Sign_symptom\n",
1566
      "worsening: Sign_symptom\n",
1567
      "shortness: Biological_structure\n",
1568
      "breath: Sign_symptom\n",
1569
      "chest: History\n",
1570
      "pain: History\n",
1571
      "reported: History\n",
1572
      "recent: O\n",
1573
      "travel: O\n",
1574
      "sick: O\n",
1575
      "contacts: History\n",
1576
      "medical: History\n",
1577
      "history: History\n",
1578
      "significant: History\n",
1579
      "hypertension: History\n",
1580
      "dyslipidemia: History\n",
1581
      "type: O\n",
1582
      "2: O\n",
1583
      "diabetes: Diagnostic_procedure\n",
1584
      "mellitus: Diagnostic_procedure\n",
1585
      "examination: Lab_value\n",
1586
      "tachycardic: Detailed_description\n",
1587
      "tachypneic: Detailed_description\n",
1588
      "oxygen: Biological_structure\n",
1589
      "saturation: Diagnostic_procedure\n",
1590
      "88: Detailed_description\n",
1591
      "room: O\n",
1592
      "air: Biological_structure\n",
1593
      "chest: Sign_symptom\n",
1594
      "radiography: O\n",
1595
      "revealed: Nonbiological_location\n",
1596
      "bilateral: Nonbiological_location\n",
1597
      "opacities: Nonbiological_location\n",
1598
      "consistent: O\n",
1599
      "pulmonary: Detailed_description\n",
1600
      "edema: Therapeutic_procedure\n",
1601
      "patient: Distance\n",
1602
      "admitted: Administration\n",
1603
      "intensive: Medication\n",
1604
      "care: Medication\n",
1605
      "unit: Medication\n",
1606
      "management: O\n",
1607
      "acute: O\n",
1608
      "decompensated: Nonbiological_location\n",
1609
      "heart: Clinical_event\n",
1610
      "failure: O\n",
1611
      "started: Nonbiological_location\n",
1612
      "intravenous: Duration\n",
1613
      "diuretics: Duration\n",
1614
      "inotropic: O\n",
1615
      "support: O\n",
1616
      "dobutamine: O\n",
1617
      "next: O\n",
1618
      "several: O\n",
1619
      "days: O\n",
1620
      "symptoms: O\n",
1621
      "improved: O\n",
1622
      "discharged: O\n",
1623
      "home: O\n",
1624
      "instructions: O\n",
1625
      "follow: O\n",
1626
      "primary: O\n",
1627
      "care: O\n",
1628
      "provider: O\n",
1629
      "1: O\n",
1630
      "week: O\n"
1631
     ]
1632
    },
1633
    {
1634
     "data": {
1635
      "text/html": [
1636
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
1637
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1638
       "    57\n",
1639
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1640
       "</mark>\n",
1641
       "-\n",
1642
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1643
       "    year\n",
1644
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1645
       "</mark>\n",
1646
       "-\n",
1647
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1648
       "    old\n",
1649
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1650
       "</mark>\n",
1651
       " \n",
1652
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1653
       "    man\n",
1654
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
1655
       "</mark>\n",
1656
       " \n",
1657
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1658
       "    presented\n",
1659
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1660
       "</mark>\n",
1661
       " to the \n",
1662
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1663
       "    emergency\n",
1664
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1665
       "</mark>\n",
1666
       " \n",
1667
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1668
       "    department\n",
1669
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1670
       "</mark>\n",
1671
       " with a \n",
1672
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1673
       "    2\n",
1674
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1675
       "</mark>\n",
1676
       "-day \n",
1677
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1678
       "    history\n",
1679
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1680
       "</mark>\n",
1681
       " of \n",
1682
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1683
       "    worsening\n",
1684
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1685
       "</mark>\n",
1686
       " \n",
1687
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1688
       "    shortness\n",
1689
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1690
       "</mark>\n",
1691
       " of \n",
1692
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1693
       "    breath\n",
1694
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1695
       "</mark>\n",
1696
       " and \n",
1697
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1698
       "    chest\n",
1699
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1700
       "</mark>\n",
1701
       " \n",
1702
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1703
       "    pain\n",
1704
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1705
       "</mark>\n",
1706
       ". He \n",
1707
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1708
       "    reported\n",
1709
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1710
       "</mark>\n",
1711
       " no recent travel or sick \n",
1712
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1713
       "    contacts\n",
1714
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1715
       "</mark>\n",
1716
       ". His \n",
1717
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1718
       "    medical\n",
1719
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1720
       "</mark>\n",
1721
       " \n",
1722
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1723
       "    history\n",
1724
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1725
       "</mark>\n",
1726
       " was \n",
1727
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1728
       "    significant\n",
1729
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1730
       "</mark>\n",
1731
       " for \n",
1732
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1733
       "    hypertension\n",
1734
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1735
       "</mark>\n",
1736
       ", \n",
1737
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1738
       "    dyslipidemia\n",
1739
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
1740
       "</mark>\n",
1741
       ", and type 2 \n",
1742
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1743
       "    diabetes\n",
1744
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1745
       "</mark>\n",
1746
       " \n",
1747
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1748
       "    mellitus\n",
1749
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1750
       "</mark>\n",
1751
       ". On \n",
1752
       "<mark class=\"entity\" style=\"background: #f4b3c2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1753
       "    examination\n",
1754
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Lab_value</span>\n",
1755
       "</mark>\n",
1756
       ", he was \n",
1757
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1758
       "    tachycardic\n",
1759
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1760
       "</mark>\n",
1761
       " and \n",
1762
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1763
       "    tachypneic\n",
1764
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1765
       "</mark>\n",
1766
       ", with \n",
1767
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1768
       "    oxygen\n",
1769
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1770
       "</mark>\n",
1771
       " \n",
1772
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1773
       "    saturation\n",
1774
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
1775
       "</mark>\n",
1776
       " of \n",
1777
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1778
       "    88\n",
1779
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1780
       "</mark>\n",
1781
       "% on room \n",
1782
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1783
       "    air\n",
1784
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
1785
       "</mark>\n",
1786
       ". \n",
1787
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1788
       "    Chest\n",
1789
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
1790
       "</mark>\n",
1791
       " radiography \n",
1792
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1793
       "    revealed\n",
1794
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1795
       "</mark>\n",
1796
       " \n",
1797
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1798
       "    bilateral\n",
1799
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1800
       "</mark>\n",
1801
       " \n",
1802
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1803
       "    opacities\n",
1804
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1805
       "</mark>\n",
1806
       " consistent with \n",
1807
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1808
       "    pulmonary\n",
1809
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
1810
       "</mark>\n",
1811
       " \n",
1812
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1813
       "    edema\n",
1814
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
1815
       "</mark>\n",
1816
       ". The \n",
1817
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1818
       "    patient\n",
1819
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
1820
       "</mark>\n",
1821
       " was \n",
1822
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1823
       "    admitted\n",
1824
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Administration</span>\n",
1825
       "</mark>\n",
1826
       " to the \n",
1827
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1828
       "    intensive\n",
1829
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1830
       "</mark>\n",
1831
       " \n",
1832
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1833
       "    care\n",
1834
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1835
       "</mark>\n",
1836
       " \n",
1837
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1838
       "    unit\n",
1839
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
1840
       "</mark>\n",
1841
       " for management of acute \n",
1842
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1843
       "    decompensated\n",
1844
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1845
       "</mark>\n",
1846
       " \n",
1847
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1848
       "    heart\n",
1849
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
1850
       "</mark>\n",
1851
       " failure. He was \n",
1852
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1853
       "    started\n",
1854
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
1855
       "</mark>\n",
1856
       " on \n",
1857
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1858
       "    intravenous\n",
1859
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1860
       "</mark>\n",
1861
       " \n",
1862
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1863
       "    diuretics\n",
1864
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
1865
       "</mark>\n",
1866
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
1867
      ],
1868
      "text/plain": [
1869
       "<IPython.core.display.HTML object>"
1870
      ]
1871
     },
1872
     "metadata": {},
1873
     "output_type": "display_data"
1874
    }
1875
   ],
1876
   "source": [
1877
    "NER(\"model_5\",\n",
1878
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
1879
   ]
1880
  },
1881
  {
1882
   "cell_type": "markdown",
1883
   "id": "fbd84584",
1884
   "metadata": {},
1885
   "source": [
1886
    "## MODEL 6"
1887
   ]
1888
  },
1889
  {
1890
   "cell_type": "code",
1891
   "execution_count": 7,
1892
   "id": "73fb52a0",
1893
   "metadata": {
1894
    "scrolled": false
1895
   },
1896
   "outputs": [
1897
    {
1898
     "name": "stdout",
1899
     "output_type": "stream",
1900
     "text": [
1901
      "Model provided:  Bidirectional LSTM Time Distirbuted Dense Layers and Convolutional 1D layer\n",
1902
      "WARNING:tensorflow:6 out of the last 6 calls to <function Model.make_predict_function.<locals>.predict_function at 0x2d766ce50> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has reduce_retracing=True option that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.\n",
1903
      "1/1 [==============================] - 0s 318ms/step\n",
1904
      "Predicted Named Entities:\n",
1905
      "57: Age\n",
1906
      "year: Age\n",
1907
      "old: Age\n",
1908
      "man: Sex\n",
1909
      "presented: Personal_background\n",
1910
      "emergency: Nonbiological_location\n",
1911
      "department: Nonbiological_location\n",
1912
      "2: Nonbiological_location\n",
1913
      "day: History\n",
1914
      "history: Sign_symptom\n",
1915
      "worsening: Sign_symptom\n",
1916
      "shortness: Biological_structure\n",
1917
      "breath: Sign_symptom\n",
1918
      "chest: History\n",
1919
      "pain: History\n",
1920
      "reported: History\n",
1921
      "recent: History\n",
1922
      "travel: History\n",
1923
      "sick: History\n",
1924
      "contacts: History\n",
1925
      "medical: History\n",
1926
      "history: History\n",
1927
      "significant: History\n",
1928
      "hypertension: History\n",
1929
      "dyslipidemia: History\n",
1930
      "type: Sign_symptom\n",
1931
      "2: Sign_symptom\n",
1932
      "diabetes: Biological_structure\n",
1933
      "mellitus: Diagnostic_procedure\n",
1934
      "examination: Detailed_description\n",
1935
      "tachycardic: Detailed_description\n",
1936
      "tachypneic: Detailed_description\n",
1937
      "oxygen: Biological_structure\n",
1938
      "saturation: Diagnostic_procedure\n",
1939
      "88: Lab_value\n",
1940
      "room: O\n",
1941
      "air: Biological_structure\n",
1942
      "chest: Detailed_description\n",
1943
      "radiography: O\n",
1944
      "revealed: Nonbiological_location\n",
1945
      "bilateral: Nonbiological_location\n",
1946
      "opacities: Nonbiological_location\n",
1947
      "consistent: O\n",
1948
      "pulmonary: Detailed_description\n",
1949
      "edema: Detailed_description\n",
1950
      "patient: Detailed_description\n",
1951
      "admitted: Therapeutic_procedure\n",
1952
      "intensive: Medication\n",
1953
      "care: Therapeutic_procedure\n",
1954
      "unit: Therapeutic_procedure\n",
1955
      "management: Dosage\n",
1956
      "acute: Dosage\n",
1957
      "decompensated: Dosage\n",
1958
      "heart: O\n",
1959
      "failure: Medication\n",
1960
      "started: Medication\n",
1961
      "intravenous: Duration\n",
1962
      "diuretics: Duration\n",
1963
      "inotropic: O\n",
1964
      "support: O\n",
1965
      "dobutamine: O\n",
1966
      "next: O\n",
1967
      "several: O\n",
1968
      "days: O\n",
1969
      "symptoms: O\n",
1970
      "improved: O\n",
1971
      "discharged: O\n",
1972
      "home: O\n",
1973
      "instructions: O\n",
1974
      "follow: O\n",
1975
      "primary: O\n",
1976
      "care: O\n",
1977
      "provider: O\n",
1978
      "1: O\n",
1979
      "week: O\n"
1980
     ]
1981
    },
1982
    {
1983
     "data": {
1984
      "text/html": [
1985
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
1986
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1987
       "    57\n",
1988
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1989
       "</mark>\n",
1990
       "-\n",
1991
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1992
       "    year\n",
1993
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1994
       "</mark>\n",
1995
       "-\n",
1996
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
1997
       "    old\n",
1998
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
1999
       "</mark>\n",
2000
       " \n",
2001
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2002
       "    man\n",
2003
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
2004
       "</mark>\n",
2005
       " \n",
2006
       "<mark class=\"entity\" style=\"background: #a0ced9; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2007
       "    presented\n",
2008
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Personal_background</span>\n",
2009
       "</mark>\n",
2010
       " to the \n",
2011
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2012
       "    emergency\n",
2013
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2014
       "</mark>\n",
2015
       " \n",
2016
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2017
       "    department\n",
2018
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2019
       "</mark>\n",
2020
       " with a \n",
2021
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2022
       "    2\n",
2023
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2024
       "</mark>\n",
2025
       "-\n",
2026
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2027
       "    day\n",
2028
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2029
       "</mark>\n",
2030
       " \n",
2031
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2032
       "    history\n",
2033
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2034
       "</mark>\n",
2035
       " of \n",
2036
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2037
       "    worsening\n",
2038
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2039
       "</mark>\n",
2040
       " \n",
2041
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2042
       "    shortness\n",
2043
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2044
       "</mark>\n",
2045
       " of \n",
2046
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2047
       "    breath\n",
2048
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2049
       "</mark>\n",
2050
       " and \n",
2051
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2052
       "    chest\n",
2053
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2054
       "</mark>\n",
2055
       " \n",
2056
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2057
       "    pain\n",
2058
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2059
       "</mark>\n",
2060
       ". He \n",
2061
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2062
       "    reported\n",
2063
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2064
       "</mark>\n",
2065
       " no \n",
2066
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2067
       "    recent\n",
2068
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2069
       "</mark>\n",
2070
       " \n",
2071
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2072
       "    travel\n",
2073
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2074
       "</mark>\n",
2075
       " or \n",
2076
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2077
       "    sick\n",
2078
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2079
       "</mark>\n",
2080
       " \n",
2081
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2082
       "    contacts\n",
2083
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2084
       "</mark>\n",
2085
       ". His \n",
2086
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2087
       "    medical\n",
2088
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2089
       "</mark>\n",
2090
       " \n",
2091
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2092
       "    history\n",
2093
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2094
       "</mark>\n",
2095
       " was \n",
2096
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2097
       "    significant\n",
2098
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2099
       "</mark>\n",
2100
       " for \n",
2101
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2102
       "    hypertension\n",
2103
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2104
       "</mark>\n",
2105
       ", \n",
2106
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2107
       "    dyslipidemia\n",
2108
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2109
       "</mark>\n",
2110
       ", and \n",
2111
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2112
       "    type\n",
2113
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2114
       "</mark>\n",
2115
       " \n",
2116
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2117
       "    2\n",
2118
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2119
       "</mark>\n",
2120
       " \n",
2121
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2122
       "    diabetes\n",
2123
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2124
       "</mark>\n",
2125
       " \n",
2126
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2127
       "    mellitus\n",
2128
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
2129
       "</mark>\n",
2130
       ". On \n",
2131
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2132
       "    examination\n",
2133
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2134
       "</mark>\n",
2135
       ", he was \n",
2136
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2137
       "    tachycardic\n",
2138
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2139
       "</mark>\n",
2140
       " and \n",
2141
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2142
       "    tachypneic\n",
2143
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2144
       "</mark>\n",
2145
       ", with \n",
2146
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2147
       "    oxygen\n",
2148
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2149
       "</mark>\n",
2150
       " \n",
2151
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2152
       "    saturation\n",
2153
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
2154
       "</mark>\n",
2155
       " of \n",
2156
       "<mark class=\"entity\" style=\"background: #f4b3c2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2157
       "    88\n",
2158
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Lab_value</span>\n",
2159
       "</mark>\n",
2160
       "% on room \n",
2161
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2162
       "    air\n",
2163
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2164
       "</mark>\n",
2165
       ". \n",
2166
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2167
       "    Chest\n",
2168
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2169
       "</mark>\n",
2170
       " radiography \n",
2171
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2172
       "    revealed\n",
2173
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2174
       "</mark>\n",
2175
       " \n",
2176
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2177
       "    bilateral\n",
2178
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2179
       "</mark>\n",
2180
       " \n",
2181
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2182
       "    opacities\n",
2183
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2184
       "</mark>\n",
2185
       " consistent with \n",
2186
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2187
       "    pulmonary\n",
2188
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2189
       "</mark>\n",
2190
       " \n",
2191
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2192
       "    edema\n",
2193
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2194
       "</mark>\n",
2195
       ". The \n",
2196
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2197
       "    patient\n",
2198
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2199
       "</mark>\n",
2200
       " was \n",
2201
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2202
       "    admitted\n",
2203
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
2204
       "</mark>\n",
2205
       " to the \n",
2206
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2207
       "    intensive\n",
2208
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2209
       "</mark>\n",
2210
       " \n",
2211
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2212
       "    care\n",
2213
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
2214
       "</mark>\n",
2215
       " \n",
2216
       "<mark class=\"entity\" style=\"background: #e6ccb2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2217
       "    unit\n",
2218
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Therapeutic_procedure</span>\n",
2219
       "</mark>\n",
2220
       " for \n",
2221
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2222
       "    management\n",
2223
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
2224
       "</mark>\n",
2225
       " of \n",
2226
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2227
       "    acute\n",
2228
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
2229
       "</mark>\n",
2230
       " \n",
2231
       "<mark class=\"entity\" style=\"background: #b9e8d8; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2232
       "    decompensated\n",
2233
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Dosage</span>\n",
2234
       "</mark>\n",
2235
       " heart \n",
2236
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2237
       "    failure\n",
2238
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2239
       "</mark>\n",
2240
       ". He was \n",
2241
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2242
       "    started\n",
2243
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2244
       "</mark>\n",
2245
       " on \n",
2246
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2247
       "    intravenous\n",
2248
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
2249
       "</mark>\n",
2250
       " \n",
2251
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2252
       "    diuretics\n",
2253
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
2254
       "</mark>\n",
2255
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
2256
      ],
2257
      "text/plain": [
2258
       "<IPython.core.display.HTML object>"
2259
      ]
2260
     },
2261
     "metadata": {},
2262
     "output_type": "display_data"
2263
    }
2264
   ],
2265
   "source": [
2266
    "NER(\"model_6\",\n",
2267
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
2268
   ]
2269
  },
2270
  {
2271
   "cell_type": "markdown",
2272
   "id": "e92dfa6e",
2273
   "metadata": {},
2274
   "source": [
2275
    "## MODEL 7"
2276
   ]
2277
  },
2278
  {
2279
   "cell_type": "code",
2280
   "execution_count": 8,
2281
   "id": "21b2b199",
2282
   "metadata": {
2283
    "scrolled": false
2284
   },
2285
   "outputs": [
2286
    {
2287
     "name": "stdout",
2288
     "output_type": "stream",
2289
     "text": [
2290
      "Model provided:  Bidirectional LSTM CRF model with BioWordVecEmbedding Layers followed two LSTM layers, Time Distirbuted Dense Layers and Convolutional 1D layer\n",
2291
      "1/1 [==============================] - 0s 365ms/step\n",
2292
      "Predicted Named Entities:\n",
2293
      "57: Age\n",
2294
      "year: Age\n",
2295
      "old: Age\n",
2296
      "man: Sex\n",
2297
      "presented: Nonbiological_location\n",
2298
      "emergency: Nonbiological_location\n",
2299
      "department: Date\n",
2300
      "2: Duration\n",
2301
      "day: O\n",
2302
      "history: Sign_symptom\n",
2303
      "worsening: Detailed_description\n",
2304
      "shortness: Biological_structure\n",
2305
      "breath: Sign_symptom\n",
2306
      "chest: History\n",
2307
      "pain: History\n",
2308
      "reported: History\n",
2309
      "recent: History\n",
2310
      "travel: History\n",
2311
      "sick: History\n",
2312
      "contacts: History\n",
2313
      "medical: History\n",
2314
      "history: History\n",
2315
      "significant: History\n",
2316
      "hypertension: History\n",
2317
      "dyslipidemia: History\n",
2318
      "type: O\n",
2319
      "2: Sign_symptom\n",
2320
      "diabetes: Diagnostic_procedure\n",
2321
      "mellitus: Diagnostic_procedure\n",
2322
      "examination: Lab_value\n",
2323
      "tachycardic: Detailed_description\n",
2324
      "tachypneic: Detailed_description\n",
2325
      "oxygen: Biological_structure\n",
2326
      "saturation: Diagnostic_procedure\n",
2327
      "88: Detailed_description\n",
2328
      "room: O\n",
2329
      "air: Biological_structure\n",
2330
      "chest: Sign_symptom\n",
2331
      "radiography: O\n",
2332
      "revealed: Nonbiological_location\n",
2333
      "bilateral: Nonbiological_location\n",
2334
      "opacities: Nonbiological_location\n",
2335
      "consistent: O\n",
2336
      "pulmonary: Detailed_description\n",
2337
      "edema: Distance\n",
2338
      "patient: History\n",
2339
      "admitted: Detailed_description\n",
2340
      "intensive: Medication\n",
2341
      "care: Medication\n",
2342
      "unit: Medication\n",
2343
      "management: O\n",
2344
      "acute: O\n",
2345
      "decompensated: Nonbiological_location\n",
2346
      "heart: Clinical_event\n",
2347
      "failure: Nonbiological_location\n",
2348
      "started: Nonbiological_location\n",
2349
      "intravenous: Date\n",
2350
      "diuretics: Duration\n",
2351
      "inotropic: O\n",
2352
      "support: O\n",
2353
      "dobutamine: O\n",
2354
      "next: O\n",
2355
      "several: O\n",
2356
      "days: O\n",
2357
      "symptoms: O\n",
2358
      "improved: O\n",
2359
      "discharged: O\n",
2360
      "home: O\n",
2361
      "instructions: O\n",
2362
      "follow: O\n",
2363
      "primary: O\n",
2364
      "care: O\n",
2365
      "provider: O\n",
2366
      "1: O\n",
2367
      "week: O\n"
2368
     ]
2369
    },
2370
    {
2371
     "data": {
2372
      "text/html": [
2373
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">A \n",
2374
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2375
       "    57\n",
2376
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
2377
       "</mark>\n",
2378
       "-\n",
2379
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2380
       "    year\n",
2381
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
2382
       "</mark>\n",
2383
       "-\n",
2384
       "<mark class=\"entity\" style=\"background: #f6c3d0; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2385
       "    old\n",
2386
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Age</span>\n",
2387
       "</mark>\n",
2388
       " \n",
2389
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2390
       "    man\n",
2391
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sex</span>\n",
2392
       "</mark>\n",
2393
       " \n",
2394
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2395
       "    presented\n",
2396
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2397
       "</mark>\n",
2398
       " to the \n",
2399
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2400
       "    emergency\n",
2401
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2402
       "</mark>\n",
2403
       " \n",
2404
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2405
       "    department\n",
2406
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
2407
       "</mark>\n",
2408
       " with a \n",
2409
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2410
       "    2\n",
2411
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
2412
       "</mark>\n",
2413
       "-day \n",
2414
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2415
       "    history\n",
2416
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2417
       "</mark>\n",
2418
       " of \n",
2419
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2420
       "    worsening\n",
2421
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2422
       "</mark>\n",
2423
       " \n",
2424
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2425
       "    shortness\n",
2426
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2427
       "</mark>\n",
2428
       " of \n",
2429
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2430
       "    breath\n",
2431
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2432
       "</mark>\n",
2433
       " and \n",
2434
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2435
       "    chest\n",
2436
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2437
       "</mark>\n",
2438
       " \n",
2439
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2440
       "    pain\n",
2441
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2442
       "</mark>\n",
2443
       ". He \n",
2444
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2445
       "    reported\n",
2446
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2447
       "</mark>\n",
2448
       " no \n",
2449
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2450
       "    recent\n",
2451
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2452
       "</mark>\n",
2453
       " \n",
2454
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2455
       "    travel\n",
2456
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2457
       "</mark>\n",
2458
       " or \n",
2459
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2460
       "    sick\n",
2461
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2462
       "</mark>\n",
2463
       " \n",
2464
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2465
       "    contacts\n",
2466
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2467
       "</mark>\n",
2468
       ". His \n",
2469
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2470
       "    medical\n",
2471
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2472
       "</mark>\n",
2473
       " \n",
2474
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2475
       "    history\n",
2476
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2477
       "</mark>\n",
2478
       " was \n",
2479
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2480
       "    significant\n",
2481
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2482
       "</mark>\n",
2483
       " for \n",
2484
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2485
       "    hypertension\n",
2486
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2487
       "</mark>\n",
2488
       ", \n",
2489
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2490
       "    dyslipidemia\n",
2491
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2492
       "</mark>\n",
2493
       ", and type \n",
2494
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2495
       "    2\n",
2496
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2497
       "</mark>\n",
2498
       " \n",
2499
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2500
       "    diabetes\n",
2501
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
2502
       "</mark>\n",
2503
       " \n",
2504
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2505
       "    mellitus\n",
2506
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
2507
       "</mark>\n",
2508
       ". On \n",
2509
       "<mark class=\"entity\" style=\"background: #f4b3c2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2510
       "    examination\n",
2511
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Lab_value</span>\n",
2512
       "</mark>\n",
2513
       ", he was \n",
2514
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2515
       "    tachycardic\n",
2516
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2517
       "</mark>\n",
2518
       " and \n",
2519
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2520
       "    tachypneic\n",
2521
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2522
       "</mark>\n",
2523
       ", with \n",
2524
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2525
       "    oxygen\n",
2526
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2527
       "</mark>\n",
2528
       " \n",
2529
       "<mark class=\"entity\" style=\"background: #c5b4e3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2530
       "    saturation\n",
2531
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Diagnostic_procedure</span>\n",
2532
       "</mark>\n",
2533
       " of \n",
2534
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2535
       "    88\n",
2536
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2537
       "</mark>\n",
2538
       "% on room \n",
2539
       "<mark class=\"entity\" style=\"background: #9ddfd3; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2540
       "    air\n",
2541
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Biological_structure</span>\n",
2542
       "</mark>\n",
2543
       ". \n",
2544
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2545
       "    Chest\n",
2546
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Sign_symptom</span>\n",
2547
       "</mark>\n",
2548
       " radiography \n",
2549
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2550
       "    revealed\n",
2551
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2552
       "</mark>\n",
2553
       " \n",
2554
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2555
       "    bilateral\n",
2556
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2557
       "</mark>\n",
2558
       " \n",
2559
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2560
       "    opacities\n",
2561
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2562
       "</mark>\n",
2563
       " consistent with \n",
2564
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2565
       "    pulmonary\n",
2566
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2567
       "</mark>\n",
2568
       " \n",
2569
       "<mark class=\"entity\" style=\"background: #bde0fe; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2570
       "    edema\n",
2571
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Distance</span>\n",
2572
       "</mark>\n",
2573
       ". The \n",
2574
       "<mark class=\"entity\" style=\"background: #e2f0cb; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2575
       "    patient\n",
2576
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">History</span>\n",
2577
       "</mark>\n",
2578
       " was \n",
2579
       "<mark class=\"entity\" style=\"background: #ffb347; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2580
       "    admitted\n",
2581
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Detailed_description</span>\n",
2582
       "</mark>\n",
2583
       " to the \n",
2584
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2585
       "    intensive\n",
2586
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2587
       "</mark>\n",
2588
       " \n",
2589
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2590
       "    care\n",
2591
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2592
       "</mark>\n",
2593
       " \n",
2594
       "<mark class=\"entity\" style=\"background: #f9d5e5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2595
       "    unit\n",
2596
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Medication</span>\n",
2597
       "</mark>\n",
2598
       " for management of acute \n",
2599
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2600
       "    decompensated\n",
2601
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2602
       "</mark>\n",
2603
       " \n",
2604
       "<mark class=\"entity\" style=\"background: #77c5d5; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2605
       "    heart\n",
2606
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Clinical_event</span>\n",
2607
       "</mark>\n",
2608
       " \n",
2609
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2610
       "    failure\n",
2611
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2612
       "</mark>\n",
2613
       ". He was \n",
2614
       "<mark class=\"entity\" style=\"background: #f7a399; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2615
       "    started\n",
2616
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Nonbiological_location</span>\n",
2617
       "</mark>\n",
2618
       " on \n",
2619
       "<mark class=\"entity\" style=\"background: #f1f0d2; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2620
       "    intravenous\n",
2621
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Date</span>\n",
2622
       "</mark>\n",
2623
       " \n",
2624
       "<mark class=\"entity\" style=\"background: #ffdfba; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
2625
       "    diuretics\n",
2626
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">Duration</span>\n",
2627
       "</mark>\n",
2628
       " and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.</div></span>"
2629
      ],
2630
      "text/plain": [
2631
       "<IPython.core.display.HTML object>"
2632
      ]
2633
     },
2634
     "metadata": {},
2635
     "output_type": "display_data"
2636
    }
2637
   ],
2638
   "source": [
2639
    "NER(\"model_7\",\n",
2640
    "        \"A 57-year-old man presented to the emergency department with a 2-day history of worsening shortness of breath and chest pain. He reported no recent travel or sick contacts. His medical history was significant for hypertension, dyslipidemia, and type 2 diabetes mellitus. On examination, he was tachycardic and tachypneic, with oxygen saturation of 88% on room air. Chest radiography revealed bilateral opacities consistent with pulmonary edema. The patient was admitted to the intensive care unit for management of acute decompensated heart failure. He was started on intravenous diuretics and inotropic support with dobutamine. Over the next several days, his symptoms improved and he was discharged to home with instructions to follow up with his primary care provider in 1 week.\")"
2641
   ]
2642
  },
2643
  {
2644
   "cell_type": "code",
2645
   "execution_count": null,
2646
   "id": "753f82ed",
2647
   "metadata": {},
2648
   "outputs": [],
2649
   "source": []
2650
  }
2651
 ],
2652
 "metadata": {
2653
  "kernelspec": {
2654
   "display_name": "Python 3 (ipykernel)",
2655
   "language": "python",
2656
   "name": "python3"
2657
  },
2658
  "language_info": {
2659
   "codemirror_mode": {
2660
    "name": "ipython",
2661
    "version": 3
2662
   },
2663
   "file_extension": ".py",
2664
   "mimetype": "text/x-python",
2665
   "name": "python",
2666
   "nbconvert_exporter": "python",
2667
   "pygments_lexer": "ipython3",
2668
   "version": "3.8.10"
2669
  }
2670
 },
2671
 "nbformat": 4,
2672
 "nbformat_minor": 5
2673
}