| Server IP : 54.37.205.81 / Your IP : 216.73.216.76 Web Server : nginx/1.22.1 System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64 User : debian ( 1000) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/nltk/chat/__pycache__/ |
Upload File : |
�
T�c2 � � � d dl Z d dlZi dd�dd�dd�dd�d d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�Z G d� d� � ZdS )� Nzi amzyou arezi waszyou were�i�youzi'mzi'dz you wouldzi'vezyou havezi'llzyou will�my�yourzI amzI waszyou'vezI havezyou'llzI will�yours�mine�mec �8 � e Zd Zi fd�Zd� Zd� Zd� Zd� Zd d�ZdS )
�Chatc �h � d� |D � � | _ || _ | � � � | _ dS )a�
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
c �V � g | ]&\ }}t j |t j � � |f��'S � )�re�compile�
IGNORECASE)�.0�x�ys �0/usr/lib/python3/dist-packages/nltk/chat/util.py�
<listcomp>z!Chat.__init__.<locals>.<listcomp>3 s/ � �M�M�M�V�a���
�1�b�m�4�4�a�8�M�M�M� N)�_pairs�_reflections�_compile_reflections�_regex)�self�pairs�reflectionss r �__init__z
Chat.__init__# s9 � � N�M�u�M�M�M���'����/�/�1�1����r c
�� � t | j t d�� � }t j d� d� t t j |� � � � � � t j � � S )NT)�key�reversez\b({})\b�|)
�sortedr �lenr r �format�join�map�escaper )r �sorted_refls r r zChat._compile_reflections7 sZ � ��T�.�C��F�F�F���z����s�x�x��B�I�{�(C�(C�D�D�E�E�r�}�
�
�
r c �d � � � j � � fd�|� � � � � S )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 � �� �j | j | � � � | � � � � S )N)r �string�start�end)�mor s �r �<lambda>z"Chat._substitute.<locals>.<lambda>H s+ �� �t�(���2�8�8�:�:������3H�)I�J� r )r �sub�lower)r �strs ` r �_substitutezChat._substitute= s3 �� � �{���J�J�J�J�C�I�I�K�K�
�
�
r c �. � |� d� � }|dk ryt ||dz |dz � � � }|d |� | � |� |� � � � z ||dz d � z }|� d� � }|dk �y|S )N�%r � � )�find�intr5 �group)r �response�match�pos�nums r �
_wildcardszChat._wildcardsK s� � ��m�m�C� � ���Q�h�h��h�s�Q�w��q��0�1�2�2�C���#����"�"�5�;�;�s�#3�#3�4�4�5��3��7�9�9�%�&�
�
�-�-��$�$�C� �Q�h�h� �r c � � | j D ]�\ }}|� |� � }|rdt j |� � }| � ||� � }|dd� dk r
|dd� dz }|dd� dk r
|dd� dz }|c S ��dS )z�
Generate a response to the user input.
:type str: str
:param str: The string to be mapped
:rtype: str
���Nz?.�.z??�?)r r>