-ķ
H<c    
   sŗ    d  Z    d k Z d k Z  d k T d k l Z  d k T d k T e i d  Z 6 d d  Z	 B d   Z
 H d d	  Z Y d e i d
  Z m e i d  Z  d d  Z  d   Z Ŗ d e e e e e e i e e i d 	 Z Ī d e e e e e i e d  Z ē e i e e i d  Z ł e e e e e i d  Z d e e e d  Z d e e d  Z .d e e d  Z ?d e e e d  Z `d   Z  hd   Z! d   Z" d e e# e$ d  Z% d e e& e' e( e)  d  Z* e e+ d d f e e+ d d f d e, e- e' d  d  d d! f e e. e/ d e0 f d" e1 e- d d d# f f Z2 §e e2 d$  Z3 ¹e3 Z4 »e e+ d d f e e+ d d f d e, e5 e' d  d  d d! f e e. e/ d e0 f d" e1 e5 d d d# f f Z6 Će6 d%  Z7 Īe e, e8 d f d& e, e- e# d d f e e. e/ d e0 f f Z9 Ōe& e8 d'  Z: åd k; Z; ęd( f  d)     YZ< d* d+  Z= e> d, j o e=   n d S(-   s<   mxTextTools - A tools package for fast text processing.

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
N(   s   *(   s   __version__c    sf   " # |  | } $ d }	 % d }
 & | d  \ } } } ' t |  d j o ' | d }	 n ( t |  d j o ( | d }
 n ) t	 | d  \ } } * t | } + t |  | j o | d d f j o , d } nX - | t j o . d	 } n; 0 t |  } 1 t |  d
 j o 2 | d
  d } n 3 d t |  d | | f |	 |
 f Sd S(   s7    Returns a pp-formatted tag table entry as string 
    i    i   i   i   i   s   Tables   SubTables   <table>s   Here/Toi   s   ...s#   %-15.15s : %-30s : jne=%+i : je=%+is   %-.15s : %sN(   s   tables   is   es   jnes   jes   ts   cs   ms   lens   divmods   flagss   cmds   id2cmds   types	   TupleTypes   Nones   repr(   s   tables   is	   TupleTypes   cs   es   cmds   ms   flagss   ts   jnes   je(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   format_entry s&   		  )i’’’’c    s   6 8 : g  } ; xk t t |    D; ]T } < | | j o! = | i d t |  |   n ? | i d t |  |   q% W@ t i	 | d  d Sd S(   s;    Returns a pp-formatted version of the tag table as string s   --> s       s   
N(
   s   ls   ranges   lens   tables   js   is   appends   format_entrys   strings   join(   s   tables   is   js   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   format_table6 s   	 	!!c    s   B E F t  |   GHd S(   s    Print the tag table 
    N(   s   format_tables   table(   s   table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   print_tagtableB s   i    c 	   s  H K L x| DL ]\ } } } } M t |  } N t |  d j o O | d  d } n P t |  | | ! } Q t |  d j o R | d  d } n S | t
 j o* T d | d G| Gd G| G| | f GHn> V d | d G| Gd G| G| | f GHW t |  | | d  q Wd S(	   sC    Print the taglist tags for text using the given indent level 
    i   s   ...i<   s    s    |s   : i   N(   s   tagss   tags   ls   rs   subtagss   reprs   tagnames   lens   texts   targets   Nones   indents
   print_tags(	   s   texts   tagss   indents   targets   tags   ls   rs   subtagss   tagname(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   print_tagsH s   
 *&c    s%  Y ^ _ x|  D_ ]
} ` t |  | j o` a t |  } b t |  d j o c | d  d } n d d | d G| Gd t |  GHn f | d } g | d d !\ } } h t | | | ! } i t |  d j o j | d  d } n k d | d G| Gd | | G| | f GHq Wd	 S(
   s<    Print the joinlist joins using the given indent level 
    i(   s   ...s    s    |s    (len = %i)i    i   i   N(
   s   joinss   js   types
   StringTypes   reprs   texts   lens   indents   ls   r(   s   joinss   indents
   StringTypes   rs   texts   js   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   print_joinlistY s   
 	&c    s   m w x d g t  |   } y xq t t  |    Dy ]Z } z |  | } { t |  | j o | | | | <n! ~ | d | d | d !| | <q2 W | Sd S(   sÓ    Return a normalized joinlist.

        All tuples in the joinlist are turned into real strings.  The
        resulting list is a equivalent copy of the joinlist only
        consisting of strings.
        
    s    i    i   i   N(   s   lens   jlists   ls   ranges   is   entrys   types
   StringType(   s   jlists
   StringTypes   is   entrys   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   normlistm s   
 	$c    sv     h  }  xY |  D ]N }  | | }  | i |  o  | | i |  n  | g | | <q W | Sd  S(   N(   s   ds   ls   ws   indexs   cs   has_keys   append(   s   ls   indexs   cs   ws   d(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _lookup_dict s   	
 	c    sq     g  }  t |   }  | i   }  t |  d j  oH  | i t t t	 i
 | i   d  f   | i t t d f  n  x¶ | i   D ]„ \ } }  | i t   t |  d }  x4 | D ]) }  | i t t | d d t f  q× W  | i t t t f  ¢ t t | t |  | f | | <q W£ | i t t t f  ¤ t |  Sd S(   s9    Creates a lookup table that matches the words in l 
    i   s    i’’’’i   N(   s   ts   _lookup_dicts   ls   ds   keyss   lens   appends   Nones   IsIns   strings   joins   Skips   itemss   cs   groups   is   ws   Words   MatchOks   Fails   Heres   Iss   tuple(   s   ls   groups   ds   keyss   cs   is   ts   w(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   word_in_list s$   	+ 
 	''c    s)  Ŗ · ø |
 |  | j o ¹ | |  } n » | } ¼ | i } ½ | t j oM ¾ | d j o t	 |  d j  o æ |	 |  | |  Sn Ą t	 |   } n Į |  t | d f | t t t	 |  d d f |  t t f f } Ē | |  | | |  \ } } } Č | o É |  Sn Ź | |  Sd S(   sģ   A fast replacement for string.replace.
    
       what can be given as string or search object.

       This function is a good example for the AppendTagobj-flag usage
       (the taglist can be used directly as joinlist).
       
    i    i   i’’’’N(   s   types   whats
   StringTypes   SearchObjects   sos   matchs   stops   Nones   starts   lens   string_replaces   texts   withs
   sWordStarts   Skips   AppendTagobjs   Moves   ToEOFs   ts   tags   founds   taglists   lasts   join(   s   texts   whats   withs   starts   stops   SearchObjects   joins   joinlists   tags   string_replaces   types
   StringTypes   lasts   sos   ts   founds   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   replaceŖ s   	#@!c
    s¾   Ī Ü Ż | t j o Ž t |   } n ß t |  | j o ą |	 |  } n į | t	 | d d f f } ā | |  | | |  \ } } }
 ć | o ä |  Sn å | | |  |   Sd S(   s  Analogon to string.replace; returns a string with all occurences
       of what in text[start:stop] replaced by with
       - uses a one entry tag-table and a Boyer-Moore-Search-object
       - what can be a string or a BMS/FS search object
       - it's faster than string.replace in those cases, where
         the what-string gets long and/or many replacements are found;
         faster meaning from a few percent up to many times as fast
       - start and stop define the slice of text to work in
       - stop defaults to len(text)
    i   i    N(   s   stops   Nones   lens   texts   types   whats
   StringTypes   BMSs   withs	   sFindWords   ts   tags   starts   founds   taglists   lasts   joins   joinlist(   s   texts   whats   withs   starts   stops   joins   joinlists   tags
   StringTypes   BMSs   lasts   ts   founds   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace2Ī s   !c    sĻ   ē ģ t  |  | j o ķ | |  } n ī | i |   } ļ | o š |  Sn ń g  } ņ d }	 ó x; | Dó ]0 \ }
 } ō | i |  |	 |
 !|  õ | }	 qp Wö | i |  |	  ÷ | | d  Sd  S(   Ni    s    (   s   types   whats
   StringTypes   FSs   findalls   texts   slicess   ls   xs   lefts   rights   appends   withs   join(   s   texts   whats   withs   joins   FSs
   StringTypes   slicess   ls   rights   xs   left(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace3ē s   		
 c    sæ   ł ž t  |  | j o ’ | |  } n  | i |   } | o |  Sn t g t |  }
 x5 t
 t |   D] }	 | f | |	 |
 |	 <q W| | |  |
   Sd  S(   N(   s   types   whats
   StringTypes   FSs   findalls   texts   slicess   Nones   lens   repls   ranges   is   withs   joins   joinlist(   s   texts   whats   withs   joins   joinlists   tags   FSs
   StringTypes   slicess   is   repl(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace4ł s    	c    sS   | t j	 o  | | |  | | |   Sn | | |  | |   Sd S(   sØ   Apply multiple replacement to a text at once.

        replacements must be list of tuples (replacement, left,
        right).  It is used to replace the slice text[left:right] with
        the string replacement.

        Note that the replacements do not affect one another.  Indices
        always refer to the original text string.

        Replacements must not overlap. Otherwise a ValueError is
        raised.

    N(   s   stops   Nones   joins   joinlists   texts   replacementss   start(   s   texts   replacementss   starts   stops   joins   joinlist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   multireplaces    c    sS   ()| t j	 o  *| |  i |  | |  Sn ,| |  i |  |  Sd S(   s   A faster replacement for string.find().

        Uses a search object for the task. Returns the position of the
        first occurance of what in text[start:stop]. stop defaults to
        len(text).  Returns -1 in case no occurance was found.
        
    N(   s   stops   Nones   SearchObjects   whats   finds   texts   start(   s   texts   whats   starts   stops   SearchObject(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   finds   
 c    sS   .9:| t j	 o  ;| |  i |  | |  Sn =| |  i |  |  Sd S(   s   Find all occurances of what in text.

        Uses a search object for the task. Returns a list of slice
        tuples (l,r) marking the all occurances in
        text[start:stop]. stop defaults to len(text).  Returns an
        empty list in case no occurance was found.
        
    N(   s   stops   Nones   SearchObjects   whats   findalls   texts   start(   s   texts   whats   starts   stops   SearchObject(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   findall.s    c    sä   ?MN| o O| | |  }	 n Q| |  }	 R| o S|	 i |  | |  }
 n U|	 i |  |  }
 Vd } Wg  } X| i } Yx4 |
 DY]) \ } } Z| |  | | ! [| } q W\| |  |  ]| Sd S(   s   A faster replacement for string.split().

        Uses a search object for the task. Returns the result of
        cutting the text[start:stop] string into snippets at every sep
        occurance in form of a list of substrings. translate is passed
        to the search object as translation string.

        XXX convert to a C function... or even better, add as method
        to search objects.

    i    N(   s	   translates   SearchObjects   seps   sos   stops   findalls   texts   starts   cutss   ls   lists   appends   lefts   right(   s   texts   seps   starts   stops	   translates   SearchObjects   rights   lists   ls   sos   cutss   appends   left(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   split?s    

		
 c 	   sy   `bxl | Db]a \ } } } } c| t |  } d|  | | !| | <e| o ft
 |  | | d |  n q Wd  S(   Ns   .(   s   taglists   os   ls   rs   ss   prefixs   strs   pfxs   texts   dicts   _tagdict(	   s   texts   dicts   prefixs   taglists   os   ls   ss   rs   pfx(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _tagdict`s   
 
c    sŪ   hstt  t |  f |  \ } } } u| o v| t | f Sn wh  } xt	 } yxh | Dy]] \ } } }	 } zt |  }
 {|  | |	 !| |
 <|| o }| |  t |
 d |  n qc W~| | | f Sd S(   sŻ   Tag a text just like the function tag() and then convert
        its output into a dictionary where the tagobjects reference
        their respective strings
        - this function emulates the interface of tag()
        - in contrast to tag() this funtion *does* make copies
          of the found stings
        - returns a tuple (rc,tagdict,next) with the same meaning
          of rc and next as tag(); tagdict is the new dictionary - 
          None in case rc is 0
    s   .N(   s   applys   tags   texts   argss   rcs   taglists   nexts   Nones   ds   _tagdicts   tagdicts   os   ls   rs   ss   strs   pfxs   dict(   s   texts   argss   ds   tagdicts   ls   os   nexts   ss   rcs   rs   pfxs   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   tagdicths   "		
 
"c    s   t  |  d  Sd S(   sB    Return a set with all characters *except* the ones in chars.
    i    N(   s   sets   chars(   s   chars(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   invsets   c    sR   | t j o t |   } n | |  | | |  } | d j  Sd S(   s    Return 1 iff text[start:stop] only contains whitespace
        characters (as defined in Constants/Sets.py), 0 otherwise.
    i    N(   s   stops   Nones   lens   texts   setfinds   nonwhitespaces   starts   i(   s   texts   starts   stops   nonwhitespaces   setfinds   i(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   is_whitespaces
   s    c    s#   | | |  |  |  Sd S(   sį    Eliminates newline characters and compresses whitespace
        characters into one space.

        The result is a one line text string. Tim Peters will like
        this function called with '-' separator ;-)
        
    N(   s   joins   setsplits   texts   collapse_sets	   separator(   s   texts	   separators   joins   setsplits   collapse_set(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   collapses   
s   i   s   
s   lines   
iž’’’s
   empty lineiü’’’c    s   §µ¶| |  |  d Sd S(   s   Split text into a list of single lines.

        The following combinations are considered to be line-ends:
        '', '
', '
'; they may be used in any combination.  The
        line-end indicators are removed from the strings prior to
        adding them to the list.

        This function allows dealing with text files from Macs, PCs
        and Unix origins in a portable way.
        
    i   N(   s   tags   texts   linesplit_table(   s   texts   tags   linesplit_table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   splitlines§s   c    s$   ĆĖĢt  t |  |  d  Sd S(   s    Returns the number of lines in text.

        Line ends are treated just like for splitlines() in a
        portable way.
    i   N(   s   lens   tags   texts   linecount_table(   s   texts   linecount_table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   countlinesĆs   s   wordc    s   ŌŻŽ| |  |  Sd S(   sŖ    Split text into a list of single words.

        Words are separated by whitespace. The whitespace is stripped
        before adding the words to the list.
        
    N(   s   setsplits   texts   whitespace_set(   s   texts   setsplits   whitespace_set(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   splitwordsŌs   	s   _timerc      s   ęt  Z d  Z ķļd Z šd Z ņe i e i d  Z ÷e i e i d  Z że i e i d  Z	 e i e i d  Z
 	d   Z RS(   s   timer class with a quite obvious interface
        - .start() starts a fairly accurate CPU-time timer plus an
          absolute timer
        - .stop() stops the timer and returns a tuple: the CPU-time in seconds
          and the absolute time elapsed since .start() was called
    i    c    s%   ņō|   |  _ õ|   |  _ d  S(   N(   s   times   selfs   atimes   clocks   utime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   startņs   c    sF   ÷ł|   |  i |  _ ś|   |  i |  _ ū|  i |  i f Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   stop÷s   c    s=   ż’|   |  i |  _  |   |  i |  _ |  i Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   usertimeżs   c    s=   |   |  i |  _ |   |  i |  _ |  i Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   abstimes   c    s   	d |  i |  i f Sd  S(   Ns   %0.2fu %0.2fa sec.(   s   selfs   utimes   atime(   s   self(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   __str__	s   (   s   __name__s
   __module__s   __doc__s   utimes   atimes   times   clocks   starts   stops   usertimes   abstimes   __str__(    (    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _timeręs   		s   mxTextTools/mxTextTools.cc    sa   d   } "t |   i   } #d  k } %t   } &d t |  GH(V£“d  S(   Nc    s'  Hx¾ t  t |    D]& } |  | | | j o Pn q Wd t |   t |  f GHt |   t |  j o  d t |  t |   GHn d t | t |    GHHd  Sd | GH|  | d | !d t |  |  t | |  f |  | d | d !GH Hd  S(   Ns   Length mismatch: orig=%i new=%is   Missing chars:s   Excess chars:s   Mismatch at offset %i:id   s   <- %s != %s ->i   (   s   ranges   lens   origs   is   news   repr(   s   origs   news   i(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   mismatchs    	 Hs   Working on a %i byte string(	   s   mismatchs   opens   files   reads   texts   strings   _timers   ts   len(   s   files   strings   mismatchs   texts   t(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _benchs   .)$s   __main__(?   s   __doc__s   strings   typess   mxTextToolss   __version__s   Constants.TagTabless   Constants.Setss	   TupleTypes   format_entrys   format_tables   print_tagtables
   print_tagss
   StringTypes   print_joinlists   normlists   _lookup_dicts   word_in_lists   Nones   BMSs   joins   joinlists   tags   replaces   types	   _replace2s   FSs	   _replace3s	   _replace4s   multireplaces   finds   findalls   splits   _tagdicts   tagdicts   invsets   nonwhitespace_sets   setfinds   is_whitespaces   setsplits   sets   newlines
   whitespaces   collapses   Iss   AllInSets   AppendMatchs   EOFs   Heres   MatchOks   Skips   _linesplit_tables
   splitliness	   linesplits   AppendTagobjs   _linecount_tables
   countliness   whitespace_sets   _wordsplit_tables
   splitwordss   times   _timers   _benchs   __name__("   s   _lookup_dicts   _tagdicts   format_tables   finds   replaces   _linesplit_tables   _linecount_tables   findalls   collapses   tagdicts   _timers   print_tagtables   word_in_lists   _benchs   splits
   splitwordss   __version__s
   print_tagss   format_entrys   strings   normlists   _wordsplit_tables   is_whitespaces
   countliness	   linesplits   typess   invsets   multireplaces	   _replace2s	   _replace3s
   splitliness   print_joinlists	   _replace4s   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   ? sN   


-$$!"n	n@'’ 	