³ò
èAc           @   so   d  d k  l Z d Z d Z d  d k Z d  d k Z d f  d „  ƒ  YZ e d j o e ƒ  Z e i	 ƒ  n d S(   iÿÿÿÿ(   t   nested_scopess   Hugo Liu <hugo@media.mit.edu>s   2.0Nt   MontyNLGeneratorc           B   sË   e  Z d  Z d Z d „  Z d „  Z d d d d d d d „ Z d d d	 „ Z d d d
 „ Z d d d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   ./xtag_morph_english.txts   MONTYMORPH.MDFc   
         s  d GHh  } | |  _  |  i ‰  h  } | |  _ t i ƒ  i |  i ƒ } | p+ d GH|  i ƒ  t i ƒ  i |  i ƒ } n t | d ƒ } |  i } t	 i
 | i ƒ  ƒ i d ƒ } xf | D]^ } | i d ƒ \ } }	 t t d „  |	 i d ƒ ƒ ƒ }	 t ‡  f d †  |	 ƒ }	 |	 | | <q³ Wd  S(	   Ns   Loading Morph Dictionary!s*   Morph Dictionary not found...Now Building!t   rbs   
t   =c         S   s   t  |  i d  ƒ ƒ S(   t   ,(   t   tuplet   split(   t   arg_cleaned(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyt   <lambda>   s    t   ;c            s   |  d  ˆ  |  d ƒ f S(   i    i   (    (   R   (   t	   hostnames(    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR      s    (   t   features_dictt   get_featurest
   morph_dictt
   MontyUtilst	   find_filet   morph_dict_filenamet   build_morph_dictt   opent   setitemt   zlibt
   decompresst   readR   R   t   map(
   t   selft   tmp_strt   alias_cleanedt   cmp_pt   case_pt
   groups_arrt   catst   namest   outputt
   domain_arr(    (   R
   sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyt   __init__   s(    			
	 !c   
      C   sˆ  t  |  i | ƒ } d } d } xZ| t | ƒ j  oF| d j oj | | d i ƒ  } | d d
 j o | d  } n | i ƒ  } t | ƒ d j o | d } q« d } n | | i ƒ  } t | ƒ d j o | d } n d } | i ƒ  | i ƒ  j oq | | d i ƒ  } | d d j o | d  } n | d d i | d ƒ }	 |	 | | d <| | =| d 8} n | d 7} q! Wd	 i | ƒ S(   Nt    i    i   iÿÿÿÿt   !t   .t   ?t    s     (   R$   R%   R&   (   R$   R%   R&   (   R   t   generate_sentencet   lent   stripR   t   lowert   join(
   R   t   vsoost   info_pt   groups_dictt   buf_cleanedt
   csplit_strt   groups_dictat   taggedst   mountt   env_p(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyt   generate_summary"   s4    
t   declarationt   pastR#   i   c      H   C   s  |  i  } | d d !\ }	 }
 | d } d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH gF } |
 i ƒ  i ƒ  dI j o
 dJ } n d } |  i |	 | dK dJ dL | ƒ} |  i |
 dM | d dN | dJ ƒ} g  } xÿ t t | ƒ ƒ D]ë } | | } dO } dJ } | d j o | \ } } n; | dJ j o | \ } } n | d j o | \ } } n | i ƒ  } t | ƒ dJ j o7 | d | j o& | i |  i	 | dM | dN | ƒƒ q| i |  i | dM | dN | ƒƒ qWdO } | dP j o& dQ i
 | dQ i
 | ƒ g ƒ dR } n˜| df j oG |  i |	 dX dY dK dJ ƒ} dQ i
 | | | dQ i
 | ƒ g ƒ dZ } nD| d[ j o | dg j oI dQ i
 | i ƒ  d | dQ i
 | i ƒ  dJ ƒ dQ i
 | ƒ g ƒ dZ } q@dQ i
 | | dQ i
 | ƒ g ƒ dZ } n¸ | dh j o… | di j oL dQ i
 | | i ƒ  d | dQ i
 | i ƒ  dJ ƒ dQ i
 | ƒ g ƒ dZ } q@dQ i
 | | | dQ i
 | ƒ g ƒ dZ } n& dQ i
 | | dQ i
 | ƒ g ƒ de } | i ƒ  } t | ƒ dJ j o | d i ƒ  | dJ } n | S(j   Ni    i   t   aboardt   aboutt   abovet   acrosst   aftert   againstt   alongt   amidt   amongt   antit   aroundt   ast   att   beforet   behindt   belowt   beneatht   besidet   besidest   betweent   beyondt   butt   byt
   concerningt   consideringt   despitet   downt   duringt   exceptt	   exceptingt	   excludingt	   followingt   fort   fromt   int   insidet   intot   liket   minust   neart   oft   offt   ont   ontot   oppositet   outsidet   overR8   t   pert   plust	   regardingt   roundt   savet   sincet   thant   throught   tot   towardt   towardst   undert
   underneatht   unliket   untilt   upt   upont   versust   viat   witht   withint   withoutt   ii   t   subject_numbert   ego_pt   dett   numberR#   t
   imperativeR'   R$   t   cant   mayt   wouldt   shouldt   couldt   tenset
   infinitiveR&   t   questiont   progressivet   past_progressivet   futuret   whot   whatt   whent   wheret   whyt   howR%   (   R„   s   mayR†   R‡   Rˆ   (   RŒ   R   RŽ   (   R   R   R‘   R’   R“   R”   (   RŒ   R   RŽ   (   t   conjugate_verbR*   R+   t   determine_verbt   determine_nounphraset   rangeR)   R   t   appendt   determine_prepphraseR,   t   upper(   R   t   vsoot   sentence_typeR‰   t   s_dtnumt   o1_dtnumt   o2_dtnumt   o3_dtnumt
   chroot_arrt   chownsqt   outputft   cron_pt	   file_dictt   awk_dictt   cron1t   buffer_dictt   gawk_strR0   t   objectt   buft   argsR2   t   case_pa(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR(   G   sX    	
Ø
# 
$&&&,I)L,%c   
      C   sÈ   d d d d d g } | i  ƒ  } t | ƒ d j  o | Sn | d } | d } | d } | | j o d	 i | d d !ƒ } n | d } d	 i | ƒ } |  i | d
 | d | ƒ}	 d	 i | |	 g ƒ S(   NRZ   Ra   Rp   R[   t   outi   i    i   R'   R   R‚   (   R   R)   R,   R—   (
   R   t
   prepphraseR   R‚   t   hash1R2   t   cp_cleanedkt   caset   dirname_cleanedt   cmp_str(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRš      s    



c   
   "   C   sg  d d d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" g" } | p d# Sn | i  ƒ  } t | ƒ d$ j o | d$ | j o
 d# } n t | ƒ d% j o d# } | } n d& i | d'  ƒ } | d' } |  i | d( | ƒ} | d/ j o+ | d$ }	 |	 d0 j o
 d* } qBd) } n d& i d& i | | | g ƒ i  ƒ  ƒ S(1   NR   R   R‘   t   whomt   itt   itst   hist   hert   herst   theyt   theirt   ust   yout   met   themt   thoset   theset   het   shet   wet   minet   yourst   ourst   theirst   myselft   yourselft   himselft   herselft   itselft	   ourselvest
   yourselvest
   themselvest   oneselft   myR#   i    i   R'   iÿÿÿÿR‚   t   at   ant   eR~   t   ot   u(   RÕ   s   an(   RÕ   R×   R~   RØ   RÙ   (   R   R)   R,   t
   morph_noun(
   R   t
   nounphraseR   R‚   t   gawk_cleanedR2   t	   filename1t   nice_strt   chmod_pt   output_dict(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR—   “   s$    l$





i    c   	      C   sƒ  |  i  } d } | o
 d } n d } t | i ƒ  ƒ d j o1 | i ƒ  d d j o d } | i ƒ  d } n | d j o | o | | | ƒ } nè| d j oB | o; | d j o | | | ƒ d	 } qd
 | | d ƒ } n™| d j o | o | | d ƒ } nq| d j oB | o; | d j o | | d ƒ d	 } qd | | d ƒ } n"| d j o, | o$ | d | ƒ d | | d ƒ } né | d j o+ | o$ | d | ƒ d | | d ƒ } n± | d j o | o d | | d ƒ } n… | d j o | o d | | d ƒ } nZ | d j o | o d | | d ƒ } n. | o | | d ƒ d	 } n | | d ƒ } | S(   Nt   VBZt   VBPi    i   t   nott   presentt   havet   bes    nots	   does not t   VBR8   t   VBDs   did not RŒ   R'   t   VBGs    not R   s   was s   was not RŽ   s   will (   s   haves   be(   s   haves   be(   R•   R)   R   (	   R   t   verbR‰   R   R€   R¢   t   arg_cleanedjt   chmodsR¨   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR–   ®   sD    	
0$$c         C   s>   |  i  } | i | ƒ p t | i d ƒ ƒ | | <n | | S(   Nt   |(   R   t   has_keyR   R   (   R   t   feature_stringR   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR   Ü   s    	c         C   s   |  i  ƒ  |  i ƒ  d  S(   N(   t   load_xtag_morpht   output_morph_dict(   R   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR   ã   s    
c      	   C   sä  t  d d ƒ } | i ƒ  i d ƒ } | i ƒ  g  } x. | D]& } | |  i | ƒ 7} | d g 7} q; Wt  d d ƒ } | i d i | ƒ ƒ | i ƒ  t  d d ƒ } | i ƒ  i d ƒ } t d „  | ƒ } | i ƒ  g  } x. | D]& } | |  i | ƒ 7} | d g 7} qá Wt  d	 d ƒ } | i d i | ƒ ƒ | i ƒ  t  d
 d ƒ } | i ƒ  i d ƒ } t d „  | ƒ } | i ƒ  g  } x. | D]& } | |  i | ƒ 7} | d g 7} q‡Wt  d d ƒ } | i d i | ƒ ƒ | i ƒ  d  S(   Ns   action-items.txtt   rs   
R#   s   paraphrased_actions.txtt   ws   thing-items.txtc         S   s   d  |  S(   s   see (    (   R   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR   õ   s    s   paraphrased_things.txts   place-items.txtc         S   s   d  |  S(   s   am (    (   R   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR     s    s   paraphrased_places.txt(   R   R   R   t   closet   all_egocentric_declarationst   writeR,   R   (   R   R   R   t   file_arrR   t   b_dict(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyt   reformulate_lifenetç   sH    
 

 

 
c         C   sL  | } g  } | i  ƒ  } t | ƒ d j o g  Sn | d } | d j o
 d } n d i | d ƒ } | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d	 | i ƒ  ƒ | i d
 |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d |  i | d ƒ d | i ƒ  ƒ | i d  |  i | d ƒ d | i ƒ  ƒ | i d! |  i | d ƒ d | i ƒ  ƒ | i d" |  i | d ƒ d | i ƒ  ƒ | i d# |  i | d ƒ d | i ƒ  ƒ | i d$ |  i | d ƒ d | i ƒ  ƒ | i d% |  i | d ƒ d | i ƒ  ƒ | i d& |  i | d ƒ d | i ƒ  ƒ | i d' |  i | d ƒ d | i ƒ  ƒ | i d( |  i | d ƒ d | i ƒ  ƒ | i d) |  i | d ƒ d | i ƒ  ƒ | i d* |  i | d ƒ d | i ƒ  ƒ | i d+ |  i | d ƒ d | i ƒ  ƒ | i d, |  i | d ƒ d | i ƒ  ƒ | S(-   Ni    t   amRæ   R'   i   s   I Râ   Rè   s    not s   I am Ré   s	   I am not s   I had t   VBNs	   I hadn't s   I have s
   I haven't s
   I want to Rç   s   I don't want to s   I wanted to s   I didn't want to s   I would s   I would'nt  s   I can s   I can't s   I could s   I couldn't s   I may s
   I may not s   I might s   I might not s   I must s   I must not s   I ought to s   I ought not to s   I shall s   I shall not s	   I should s   I shouldn't s   I will s   I won't s   I would have s   I wouldn't have (   R   R)   R,   R™   R•   R*   (   R   t	   simple_vpR   R÷   R2   R£   R´   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRõ     sZ    

+++++++++++++++++++++++++++++++++++c         C   sE   d } | d j o |  i  | d d g ƒ } n | p
 | } n | S(   NR#   i   s   /Nt   3pl(   t   get_morph_complex(   R   t
   noun_lemmaR‚   t   tables(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRÚ   >  s    
c         C   s4  d } | d j o |  i  | d d g ƒ } nÙ | d j o |  i  | d d g ƒ } n¯ | d j o |  i  | d d g ƒ } n… | d	 j o |  i  | d d
 g ƒ } n[ | d j o  |  i  | d d d g ƒ } n. | d j o  |  i  | d d d g ƒ } n | p
 | } n | d j o
 d } n | S(   NR#   Rç   s   /Vt   INFRè   t   PASTRé   t   PROGRû   t   PPARTRâ   t   1sgt   PRESRá   t   3sgt   wertt   was(   Rþ   (   R   t
   verb_lemmat   modeR   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR•   H  s$      

c   
      C   s´   |  i  i | g  ƒ } t | ƒ d j o d Sn g  } x` | D]X } | \ } } d } x% | D] }	 |	 | j o
 d } q\ q\ W| o | i | ƒ q= q= W| p d Sn	 | d Sd  S(   Ni    R#   i   (   R   t   getR)   R™   (
   R   t   tagged_lemmat   desired_featurest   cleanedt   popd_arrt   outputst
   stripped_pt   command_strt   chmodt   the_tokenizer_cleaned(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRþ   _  s"      c   
      C   sÄ   |  i  } | i ƒ  } | i ƒ  g  } xN | D]F } | | } d i t d „  | ƒ ƒ } | d | } | i | ƒ q, Wd i | ƒ } t i | d ƒ } t |  i	 d ƒ }	 |	 i
 | ƒ |	 i ƒ  d  S(   NR	   c         S   s   |  d  d d i  |  d ƒ S(   i    R   Rí   i   (   R,   (   R   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR     s    R   s   
i   t   wb(   R   t   keyst   sortR,   R   R™   R   t   compressR   R   Rö   Rô   (
   R   R   t   argsvR   R    R!   R   t   line_cleanedt	   info_dictRø   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRñ   w  s     	
 

c         C   sJ  t  |  i d ƒ } | i ƒ  } x| o| d d !d j o | i ƒ  } q! n | i ƒ  } t | ƒ d j  o | i ƒ  } q! n | d } d i | d ƒ i d ƒ } t d „  | ƒ } xo | D]g } | d } | d } | d	 }	 | d
 | }
 |  i i |
 g  ƒ } | i	 | |	 g ƒ | |  i |
 <qÀ W| i ƒ  } q! W| i
 ƒ  d  S(   NRò   i    i   R	   i   R'   t   #c         S   s
   |  i  ƒ  S(    (   R   (   R   (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR   ™  s    i   t   /(   R   t   xtag_morph_filenamet   readlineR   R)   R,   R   R   R  R™   Rô   (   R   R   t
   info_dictvR2   t   csplit1t   dirnamest   gawk_cleanedkR    t   hostname_strt
   chmod_dictt   dirname_arrt   args_str(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyRð   ‰  s0    

 


c         C   s   | | | <d  S(   N(    (   R   t   dictt   keyt   value(    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR   ¦  s    (   R#   i   (   R#   i   (   R#   i   (   R#   i   (   t   __name__t
   __module__R  R   R"   R6   R(   Rš   R—   R–   R   R   Rù   Rõ   RÚ   R•   Rþ   Rñ   Rð   R   (    (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pyR      s$   		%:.			&	1
				t   __main__(
   t
   __future__R    t
   __author__t   __version__R   R   R   R,  t   mRù   (    (    (    sH   /afs/cs.wisc.edu/p/zhu/06/nlp/montylingua-2.1/python/MontyNLGenerator.pys   <module>   s   ÿ £	