-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIMIC_CXR.py
45 lines (33 loc) · 1.12 KB
/
MIMIC_CXR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
import pandas as pd
from nltk.tokenize import word_tokenize,sent_tokenize
from collections import defaultdict, namedtuple
import re
data=pd.read_csv('/media/zaheer/Data/Image_Text_Datasets/MIMIC_CXR/csv_files/mimic_cxr_sectioned.csv')
print(data.findings[0])
data=data['findings'].to_list()
print(len(data))
list_words=defaultdict()
random_lst=[]
pattern = '[0-9]'
for inst in data:
#print(inst)
if not pd.isnull(inst):
inst=inst.lower()
inst1= inst.replace(',', '').replace("'", "").replace('"', '')#.replace('.', '')
inst1 = inst1.replace('&', 'and').replace('(', '').replace(")", "").replace('-', ' ').replace('___','')
inst1=re.sub(pattern, '', inst1)
lst=sent_tokenize(inst1)
#lst = word_tokenize(inst1)
#print(lst)
for word in lst:
if not word.isnumeric():
random_lst.append(word)
if not word in list_words:
list_words[word]=0
list_words[word]+=1
else:
continue
print(set(random_lst))
print(len(list_words.keys()))
print(len(set(random_lst)))