mò
c®Ec           @   sE   d  k  Z  d k Td k Td „  Z d „  Z e d j o e ƒ  n d  S(   N(   t   *c         C   s  g  }
 x_ t D]W } | i } y> t | | ƒ } |
 i g  } | D] } | | i q? ~ ƒ Wq q Xq Wt t g } h  } x7| D]/} g  } h  } d }	 x! |
 D] } | i | d f ƒ q  Wxæ t | ƒ d j oÒ | i d ƒ \ } } | | j o¬ d | | i <x) | D]! } | i |  j o | }	 Pq	q	W|	 d j  o Pn x^ | i | ƒ D]I } t  | i | i! ƒ } | i# | i ƒ p | i | | d f ƒ qPqPWqÀ qÀ W|	 | | <q W| t d j o | t d j o d Sn* | t | t j  o | t Sn	 | t Sd  S(   Ni † i    i   iÿÿÿÿ($   t   synsetst   Dictionariest   dt   post   partt   getWordt   reft   wordt   extendt   _[1]t   wt   synsett   HYPONYMt   HYPERNYMt   relation_typest   found_locationst   relation_typet   qt   visitedt   level_foundt   sst   appendt   lent   popt   levelt   maxlevelt   offsett   senset   formt   candt   getPointerst   ptrt	   getSynsett   targetOffsett   hypsst   has_key(   R   R   R   R   R   R    R
   R#   R   R   R   R   R   R   R   R   R   R   R   R   (    (    tO   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP2/evaluation/wordnet_similarity.pyt   wordnet_level   sT     	/    	 ("c          C   si  t  t i ƒ d j oJt i d }  t i d } d t t |  | d ƒ ƒ GHxX t D]P } | i	 } t |  | ƒ } | d t | ƒ GH| d  j	 o | |  j o PqR qR W| d  j o
 |  } n xX t D]P } | i	 } t | | ƒ } | d t | ƒ GH| d  j	 o | | j o PqÄ qÄ W| d  j o
 | } n d t t | | d ƒ ƒ GHd | GHd | GHn d	 GHd  S(
   Ni   i   s   Without stemming: i   s   : s   With stemming: s   c stemmed = s   r stemmed = s   Usage: 2 words as args(   R   t   syst   argvt   ct   rt   strR&   R   R   R   R   t   morphyt   c_stemt   Nonet   r_stem(   R)   R-   R   R/   R*   R   (    (    R%   t   main=   s4     		
 		
	t   __main__(   R'   t   wordnett   wntoolsR&   R0   t   __name__(   R'   R0   R&   (    (    R%   t   ?   s   		7	(