gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] pseudo AI fun


From: sjtan
Subject: [Gnumed-devel] pseudo AI fun
Date: Sat, 03 Jul 2004 20:07:07 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

visiting the old re package again.
site=   [ 'finger', 'wrist', 'thumb', 'hand', 'forearm', 'elbow', 'arm', 
'shoulder', 'neck', 'back', 'lumbar', 'thoracic', 'ribs', 'sacral', 'pelvis', 
'side', 'loin', 'hips', 'thigh','hamstring', 'groin', 'knee', 'shin', 'calf', 
'ankle', 'heel', 'foot', 'toe']

mskSite = ''.join(('(', '|'.join(site),')'))
pain='(sore\w*|pain\w*|hurt\w*)'


s = [ 'cvs', 'rs', 'gi', 'ug', 'cns', 'msk', 'skin' , 'ent']

s1= [ ('cvs', ['chest pain', 'palpitations', 'soboe', 'blackout', 'dizz', 
'faint', 'bp' ] ), 
        ('rs' , ['sob', 'cough', 'phlegm', 'wheeze', 'pleuritic', 
'(tight\w*|chest\w*){2}'] ),
        ('gi' , ['epigastric', 'ruq','lif', 'rif', 'luq', '(abdo\w+|pain){2}', 
'heartburn|reflux', 'regurg', 'vomit', 'naus', 'diarrh', 'constip', 
'(abdo\w+|upset){2}', '(altered|bowel){2}', '(change\.*|habit\w+|bowel){3}', 
'pr bleed', 'coffee grounds', 'black.*motion'] ),
        ('ug', ['blood.*urine', 'haematuria', 'urgency', 'frequency', 
'dysuria', 'hesitancy', 'nocturia']  ),
        ('cns', ['headache', 'dizziness', 'numbness', 'weakness', 'stiffness', 
'tremor', 'difficult|walk', 'fall', 'photophob', 'neck stiff', 'one|sided'  ] ),
         ('msk' ,[ mskSite + '\s+'+pain  , pain+'\s+'+mskSite  ] ) ]

re_map = {}
import re
for (k,x) in s1:
        re_map[k]= []
        for y  in x:
                print y, k
                re_map[k].append ( re.compile(y) )
        

while 1:
        inp = raw_input('>')
        model = []
        for k,v in re_map.items():
                for r in v:
                        terms = r.findall(inp)
                        if terms <> []:
                                model.append( (k, (terms, r.pattern) ) )
        
        print "The Model found was ", model
        
        
        
        




reply via email to

[Prev in Thread] Current Thread [Next in Thread]