
    /h0                         S SK r S SKr0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_r " S S5      rg)    Nzi amzyou arezi waszyou wereiyouzi'mzi'dz	you wouldzi'vezyou havezi'llzyou willmyyourzI amzI waszyou'vezI havezyou'llzI willyoursminemec                   B    \ rS rSr0 4S jrS rS rS rS rS
S jr	Sr
g	)Chat"   c                     U VVs/ s H,  u  p4[         R                  " U[         R                  5      U4PM.     snnU l        X l        U R                  5       U l        gs  snnf )ac  
Initialize the chatbot.  Pairs is a list of patterns and responses.  Each
pattern is a regular expression matching the user's statement or question,
e.g. r'I like (.*)'.  For each such pattern a list of possible responses
is given, e.g. ['Why do you like %1', 'Did you ever dislike %1'].  Material
which is matched by parenthesized sections of the patterns (e.g. .*) is mapped to
the numbered positions in the responses, e.g. %1.

:type pairs: list of tuple
:param pairs: The patterns and responses
:type reflections: dict
:param reflections: A mapping between first and second person expressions
:rtype: None
N)recompile
IGNORECASE_pairs_reflections_compile_reflections_regex)selfpairsreflectionsxys        F/var/www/auris/envauris/lib/python3.13/site-packages/nltk/chat/util.py__init__Chat.__init__#   sN      HMMuVa

1bmm4a8uM'//1 Ns   3Ac           
          [        U R                  [        SS9n[        R                  " SR                  SR                  [        [        R                  U5      5      5      [        R                  5      $ )NT)keyreversez\b({})\b|)
sortedr   lenr   r   formatjoinmapescaper   )r   sorted_refls     r   r   Chat._compile_reflections7   sO    T..CFzzsxxBII{(CDEr}}
 	
    c                 `   ^  T R                   R                  U 4S jUR                  5       5      $ )z
Substitute words in the string, according to the specified reflections,
e.g. "I'm" -> "you are"

:type str: str
:param str: The string to be mapped
:rtype: str
c                 t   > TR                   U R                  U R                  5       U R                  5           $ )N)r   stringstartend)mor   s    r   <lambda>"Chat._substitute.<locals>.<lambda>H   s'    t((288:)IJr)   )r   sublower)r   strs   ` r   _substituteChat._substitute=   s%     {{JCIIK
 	
r)   c                     UR                  S5      nUS:  aZ  [        XS-   US-    5      nUS U U R                  UR                  U5      5      -   XS-   S  -   nUR                  S5      nUS:  a  MZ  U$ )N%r         )findintr5   group)r   responsematchposnums        r   
_wildcardsChat._wildcardsK   s    mmC QhhQwq12C#""5;;s#34579%& 
 --$C Qh r)   c                     U R                    Hj  u  p#UR                  U5      nU(       d  M  [        R                  " U5      nU R	                  XT5      nUSS S:X  a  USS S-   nUSS S:X  a  USS S-   nUs  $    g)zh
Generate a response to the user input.

:type str: str
:param str: The string to be mapped
:rtype: str
Nz?..z???)r   r?   randomchoicerB   )r   r4   patternr>   r?   resps         r   respondChat.respondW   s     "&GMM#&E u}}X.t3 9$9s?D9$9s?D "-r)   c                     SnX!:w  aP  Un [        S5      nU(       a3  US   S;   a  US S nUS   S;   a  M  [        U R                  U5      5        X!:w  a  MO  g g ! [         a    [        U5         NZf = f)N >z!.)inputEOFErrorprintrL   )r   quit
user_inputs      r   converseChat.converseq   s|    
 J""3Z
  n,!+CRJ !n,dll:./    "j!"s   A A10A1)r   r   r   N)rU   )__name__
__module____qualname____firstlineno__r   r   r5   rB   rL   rW   __static_attributes__ r)   r   r   r   "   s#    *, 2(


40r)   r   )rH   r   r   r   r^   r)   r   <module>r_      s     	
IZ  
9	
 
; J J 	& v  h h D V 
4  	%!(Z0 Z0r)   