403Webshell
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/tbl/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/nltk/tbl/__pycache__/rule.cpython-311.pyc
�

 T�c�+��v�ddlmZmZddlmZGd�de���ZejGd�de����ZdS)	�)�ABCMeta�abstractmethod)�jsontagsc�H�eZdZdZd�Zd	d�Zed���Zd�Zd�Z	d�Z
dS)
�TagRulea
    An interface for tag transformations on a tagged corpus, as
    performed by tbl taggers.  Each transformation finds all tokens
    in the corpus that are tagged with a specific original tag and
    satisfy a specific condition, and replaces their tags with a
    replacement tag.  For any given transformation, the original
    tag, replacement tag, and condition are fixed.  Conditions may
    depend on the token under consideration, as well as any other
    tokens in the corpus.

    Tag rules must be comparable and hashable.
    c�$�||_	||_dS�N)�original_tag�replacement_tag)�selfr
rs   �//usr/lib/python3/dist-packages/nltk/tbl/rule.py�__init__zTagRule.__init__ s��(���B�.���F�F�Nc����|�)ttt�������}��fd�|D��}|D]}�|d�jf�|<�|S)a�
        Apply this rule at every position in positions where it
        applies to the given sentence.  I.e., for each position p
        in *positions*, if *tokens[p]* is tagged with this rule's
        original tag, and satisfies this rule's condition, then set
        its tag to be this rule's replacement tag.

        :param tokens: The tagged sentence
        :type tokens: list(tuple(str, str))
        :type positions: list(int)
        :param positions: The positions where the transformation is to
            be tried.  If not specified, try it at all positions.
        :return: The indices of tokens whose tags were changed by this
            rule.
        :rtype: int
        Nc�@��g|]}���|���|��S�)�applies)�.0�ir�tokenss  ��r
�
<listcomp>z!TagRule.apply.<locals>.<listcomp>=s,���B�B�B��$�,�,�v�q�*A�*A�B�!�B�B�Brr)�list�range�lenr)rr�	positions�changers``   r
�applyz
TagRule.apply(sw����"���U�3�v�;�;�/�/�0�0�I�C�B�B�B�B�Y�B�B�B��
�	=�	=�A����1��t�';�<�F�1�I�I��
rc��dS)a
        :return: True if the rule would change the tag of
            ``tokens[index]``, False otherwise
        :rtype: bool
        :param tokens: A tagged sentence
        :type tokens: list(str)
        :param index: The index to check
        :type index: int
        Nr)rr�indexs   r
rzTagRule.appliesGs���rc� �td���)NzRules must implement __eq__()��	TypeError�r�others  r
�__eq__zTagRule.__eq__T����7�8�8�8rc� �td���)NzRules must implement __ne__()r!r#s  r
�__ne__zTagRule.__ne__Wr&rc� �td���)NzRules must implement __hash__()r!�rs r
�__hash__zTagRule.__hash__Zs���9�:�:�:rr	)�__name__�
__module__�__qualname__�__doc__rrrrr%r(r+rrr
rrs���������G�G�G�����>�	�	��^�	�9�9�9�9�9�9�;�;�;�;�;rr)�	metaclassc�h�eZdZdZdZd�Zd�Zed���Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�ZdS)�Rulea!
    A Rule checks the current corpus position for a certain set of conditions;
    if they are all fulfilled, the Rule is triggered, meaning that it
    will change tag A to tag B. For other tags than A, nothing happens.

    The conditions are parameters to the Rule instance. Each condition is a feature-value pair,
    with a set of positions to check for the value of the corresponding feature.
    Conceptually, the positions are joined by logical OR, and the feature set by logical AND.

    More formally, the Rule is then applicable to the M{n}th token iff:

      - The M{n}th token is tagged with the Rule's original tag; and
      - For each (Feature(positions), M{value}) tuple:

        - The value of Feature of at least one token in {n+p for p in positions}
          is M{value}.
    z
nltk.tbl.Rulec�Z�t�|||��||_||_dS)ak
        Construct a new Rule that changes a token's tag from
        C{original_tag} to C{replacement_tag} if all of the properties
        specified in C{conditions} hold.

        :param templateid: the template id (a zero-padded string, '001' etc,
            so it will sort nicely)
        :type templateid: string

        :param conditions: A list of Feature(positions),
            each of which specifies that the property (computed by
            Feature.extract_property()) of at least one
            token in M{n} + p in positions is C{value}.
        :type conditions: C{iterable} of C{Feature}

        N)rr�_conditions�
templateid)rr5r
r�
conditionss     r
rz
Rule.__init__ts/��"	����|�_�=�=�=�%���$����rc�8�|j|j|j|jd�S)N)r5�original�replacementr6)r5r
rr4r*s r
�encode_json_objzRule.encode_json_obj�s(���/��)��/��*�	
�
�	
rc
�|�||d|d|dtd�|dD������S)Nr5r8r9c3�4K�|]}t|��V��dSr	��tuple)r�feats  r
�	<genexpr>z'Rule.decode_json_obj.<locals>.<genexpr>�s(����<�<�$�%��+�+�<�<�<�<�<�<rr6r=)�cls�objs  r
�decode_json_objzRule.decode_json_obj�sL���s�����
�O��
���<�<�#�l�*;�<�<�<�<�<�	
�
�	
rc���||d|jkrdS|jD]Q\}}|jD]A}d||zcxkrt|��ksn�"|�|||z��|krn�BdS�RdS)N�FrT)r
r4rr�extract_property)rrr�feature�val�poss      r
rzRule.applies�s����%�=���t�0�0�0��5�#�.�
	�
	�N�W�c��(�
�
���U�S�[�6�6�6�6�3�v�;�;�6�6�6�6���+�+�F�E�C�K�@�@�C�G�G��E�H��u�u���trc��||upC|duo?|j|jko/|j|jko|j|jko|j|jkSr	)�	__class__r
rr4r#s  r
r%zRule.__eq__�si���u�}�
����
6���4�>�1�
6��!�U�%7�7�
6��$��(=�=�
6�� �E�$5�5�	
rc��||kSr	rr#s  r
r(zRule.__ne__�s���E�M�"�"rc��	|jS#t$r+tt|����|_|jcYSwxYwr	)�_Rule__hash�AttributeError�hash�reprr*s r
r+z
Rule.__hash__�sM��	��;����	�	�	��t�D�z�z�*�*�D�K��;����	���s�	�2>�>c�&�	|jS#t$r}d�|jj|jt
|j��t
|j��d�	d�|j
D������|_|jcYSwxYw)Nz{}('{}', {}, {}, [{}])z, c3�HK�|]\}}d|�dt|���d�V��dS)�(�,�)N)rQ)r�f�vs   r
r@z Rule.__repr__.<locals>.<genexpr>�s@����L�L��!�Q�,�a�,�,�$�q�'�'�,�,�,�L�L�L�L�L�Lr)�_Rule__reprrO�formatrKr,r5rQr
r�joinr4r*s r
�__repr__z
Rule.__repr__�s���
	��;����	�	�	�2�9�9���'����T�&�'�'��T�)�*�*��	�	�L�L�4�;K�L�L�L�L�L���D�K��;����	���s�	�BB�Bc���d��d��fd�|jD����}|j�d|j�d|��}|S)Nc�~�d�|j|d�d�|jD������S)z|
            Return a compact, predicate-logic styled string representation
            of the given condition.
            z
{}:{}@[{}]rUc3�4K�|]}t|��V��dSr	)�str)r�ws  r
r@z<Rule.__str__.<locals>._condition_to_logic.<locals>.<genexpr>�s(����;�;�A��Q���;�;�;�;�;�;r)rZ�
PROPERTY_NAMEr[r)rG�values  r
�_condition_to_logicz)Rule.__str__.<locals>._condition_to_logic�sF��
 �&�&��%�����;�;��):�;�;�;�;�;���
rz & c�.��g|]\}}�||����Srr)rrWrXrds   �r
rz Rule.__str__.<locals>.<listcomp>�s+���F�F�F�6�A�q�
 �
 ��A�
&�
&�F�F�Frz->� if )r[r4r
r)rr6�srds   @r
�__str__zRule.__str__�si���		�		�		��Z�Z�F�F�F�F�T�5E�F�F�F�
�
�
�� �J�J�D�$8�J�J�j�J�J���rc���|dkr|���S|dkr|���S|dkr|���Std|�����)a�
        Return a string representation of this rule.

        >>> from nltk.tbl.rule import Rule
        >>> from nltk.tag.brill import Pos

        >>> r = Rule("23", "VB", "NN", [(Pos([-2,-1]), 'DT')])

        r.format("str") == str(r)
        True
        >>> r.format("str")
        'VB->NN if Pos:DT@[-2,-1]'

        r.format("repr") == repr(r)
        True
        >>> r.format("repr")
        "Rule('23', 'VB', 'NN', [(Pos([-2, -1]),'DT')])"

        >>> r.format("verbose")
        'VB -> NN if the Pos of words i-2...i-1 is "DT"'

        >>> r.format("not_found")
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "nltk/tbl/rule.py", line 256, in format
            raise ValueError("unknown rule format spec: {0}".format(fmt))
        ValueError: unknown rule format spec: not_found
        >>>

        :param fmt: format specification
        :type fmt: str
        :return: string representation
        :rtype: str
        r`rQ�verbosezunknown rule format spec: )rhr\�_verbose_format�
ValueError)r�fmts  r
rZzRule.format�sg��F�%�<�<��<�<�>�>�!�
�F�]�]��=�=�?�?�"�
�I�
�
��'�'�)�)�)��?�#�?�?�@�@�@rc�����fd��d��|j�d|j��}|jrdndd��fd�|jD����z}||zS)z�
        Return a wordy, human-readable string representation
        of the given rule.

        Not sure how useful this is.
        c�X��d�|j�|j��|��S)Nzthe {} of {} is "{}")rZrbr)rGrc�range_to_strs  �r
�condition_to_strz.Rule._verbose_format.<locals>.condition_to_strs4���)�0�0��%���W�.�/�/����
rc�z�t|��dkr9|d}|dkrdS|dkrdS|dkrdS|dkrd|zS|dkrd|zSdSt|��}t|��}||z
t|��dz
krd	||fzSd
�d�d�|D������S)
NrErz	this word���zthe preceding wordzthe following wordz	word i-%dz	word i+%dzwords i%+d...i%+dzwords {{{}}}rUc3� K�|]	}d|zV��
dS)zi%+dNr)r�ds  r
r@z=Rule._verbose_format.<locals>.range_to_str.<locals>.<genexpr>;s&���� ?� ?���!�� ?� ?� ?� ?� ?� ?r)r�max�minrZr[)r�p�mx�mns    r
rpz*Rule._verbose_format.<locals>.range_to_str&s����9�~�~��"�"��a�L����6�6�&�;���7�7�/�/��!�V�V�/�/���U�U�&�!��+�+���U�U�&��?�*��U���^�^����^�^����7�c�)�n�n�q�0�0�0�.�"�b��9�9�)�0�0���� ?� ?�Y� ?� ?� ?�?�?���rz -> rf�z, and c3�6�K�|]\}}�||��V��dSr	r)rrWrXrqs   �r
r@z'Rule._verbose_format.<locals>.<genexpr>?sN�����J
�J
�'-��1���Q��"�"�J
�J
�J
�J
�J
�J
r)r
rr4r[)rr9r6rqrps   @@r
rkzRule._verbose_formats�����	�	�	�	�	�	�	�	�0�*�F�F��0D�F�F�� $� 0�8�f�f�b�H�M�M�J
�J
�J
�J
�15�1A�J
�J
�J
�=
�=
�
�
��Z�'�'rN)r,r-r.r/�json_tagrr:�classmethodrCrr%r(r+r\rhrZrkrrr
r2r2^s���������$�H�%�%�%�*
�
�
��
�
��[�
����.
�
�
�#�#�#�������$���&*A�*A�*A�X+(�+(�+(�+(�+(rr2N)�abcrr�nltkrr�register_tagr2rrr
�<module>r�s���(�'�'�'�'�'�'�'�������I;�I;�I;�I;�I;��I;�I;�I;�I;�X
��c(�c(�c(�c(�c(�7�c(�c(���c(�c(�c(r

Youez - 2016 - github.com/yon3zu
LinuXploit