def information_content(synset):
 global IC_MAX
 if (not IC):
  IC[NOUN] = {}
  IC[VERB] = {}
  for s in open(IC_CORPUS).readlines()[1:]:
   s = s.split()
   (id, w, pos) = (int(s[0][:(-1)]), float(s[1]), (((s[0][(-1)] == 'n') and NOUN) or VERB))
   if ((len(s) == 3) and (s[2] == 'ROOT')):
    IC[pos][0] = (IC[pos].get(0, 0) + w)
   if (w != 0):
    IC[pos][id] = w
   if (w > IC_MAX):
    IC_MAX = w
 return (IC.get(synset.pos, {}).get(synset.id, 0.0) / IC_MAX)

def information_content ( synset ) : global IC_MAX if ( not IC ) : IC [ NOUN ] = { } IC [ VERB ] = { } for s in open ( IC_CORPUS ) . readlines ( ) [ 1 : ] : s = s . split ( ) ( id , w , pos ) = ( int ( s [ 0 ] [ : ( - 1 ) ] ) , float ( s [ 1 ] ) , ( ( ( s [ 0 ] [ ( - 1 ) ] == 'n' ) and NOUN ) or VERB ) ) if ( ( len ( s ) == 3 ) and ( s [ 2 ] == 'ROOT' ) ) : IC [ pos ] [ 0 ] = ( IC [ pos ] . get ( 0 , 0 ) + w ) if ( w != 0 ) : IC [ pos ] [ id ] = w if ( w > IC_MAX ) : IC_MAX = w return ( IC . get ( synset . pos , { } ) . get ( synset . id , 0.0 ) / IC_MAX )
returns the ic value for the given synset .