ó
    ´OÂfÙ  ã                   ó6   • S r SSKJr  SSKJr   " S S\5      rg)a(  
Multi-Word Expression Tokenizer

A ``MWETokenizer`` takes a string which has already been divided into tokens and
retokenizes it, merging multi-word expressions into single tokens, using a lexicon
of MWEs:


    >>> from nltk.tokenize import MWETokenizer

    >>> tokenizer = MWETokenizer([('a', 'little'), ('a', 'little', 'bit'), ('a', 'lot')])
    >>> tokenizer.add_mwe(('in', 'spite', 'of'))

    >>> tokenizer.tokenize('Testing testing testing one two three'.split())
    ['Testing', 'testing', 'testing', 'one', 'two', 'three']

    >>> tokenizer.tokenize('This is a test in spite'.split())
    ['This', 'is', 'a', 'test', 'in', 'spite']

    >>> tokenizer.tokenize('In a little or a little bit or a lot in spite of'.split())
    ['In', 'a_little', 'or', 'a_little_bit', 'or', 'a_lot', 'in_spite_of']

é    )Ú
TokenizerI)ÚTriec                   ó.   • \ rS rSrSrSS jrS rS rSrg)	ÚMWETokenizeré#   z`A tokenizer that processes tokenized text and merges multi-word expressions
into single tokens.
Nc                 óB   • U(       d  / n[        U5      U l        X l        g)ae  Initialize the multi-word tokenizer with a list of expressions and a
separator

:type mwes: list(list(str))
:param mwes: A sequence of multi-word expressions to be merged, where
    each MWE is a sequence of strings.
:type separator: str
:param separator: String that should be inserted between words in a multi-word
    expression token. (Default is '_')

N)r   Ú_mwesÚ
_separator)ÚselfÚmwesÚ	separators      Ú3/usr/lib/python3/dist-packages/nltk/tokenize/mwe.pyÚ__init__ÚMWETokenizer.__init__(   s   € ö ØˆDÜ˜$“ZˆŒ
Ø#�ó    c                 ó:   • U R                   R                  U5        g)a.  Add a multi-word expression to the lexicon (stored as a word trie)

We use ``util.Trie`` to represent the trie. Its form is a dict of dicts.
The key True marks the end of a valid MWE.

:param mwe: The multi-word expression we're adding into the word trie
:type mwe: tuple(str) or list(str)

:Example:

>>> tokenizer = MWETokenizer()
>>> tokenizer.add_mwe(('a', 'b'))
>>> tokenizer.add_mwe(('a', 'b', 'c'))
>>> tokenizer.add_mwe(('a', 'x'))
>>> expected = {'a': {'x': {True: None}, 'b': {True: None, 'c': {True: None}}}}
>>> tokenizer._mwes == expected
True

N)r	   Úinsert)r   Úmwes     r   Úadd_mweÚMWETokenizer.add_mwe9   s   € ð( 	�
‰
×Ñ˜#Õr   c                 ó   • Sn[        U5      n/ nX#:  aé  X   U R                  ;   a¸  UnU R                  nSnXS:  a9  X   U;   a1  XaU      nUS-   n[        R                  U;   a  UnXS:  a
  X   U;   a  M1  US:”  a  Un[        R                  U;   d  US:”  a/  UR	                  U R
                  R                  XU 5      5        UnO1UR	                  X   5        US-  nOUR	                  X   5        US-  nX#:  a  Mé  U$ )a]  

:param text: A list containing tokenized text
:type text: list(str)
:return: A list of the tokenized text with multi-words merged together
:rtype: list(str)

:Example:

>>> tokenizer = MWETokenizer([('hors', "d'oeuvre")], separator='+')
>>> tokenizer.tokenize("An hors d'oeuvre tonight, sir?".split())
['An', "hors+d'oeuvre", 'tonight,', 'sir?']

r   éÿÿÿÿé   )Úlenr	   r   ÚLEAFÚappendr
   Újoin)r   ÚtextÚiÚnÚresultÚjÚtrieÚ
last_matchs           r   ÚtokenizeÚMWETokenizer.tokenizeO   s   € ð ˆÜ�‹IˆØˆà‹eØ‰w˜$Ÿ*™*Ó$à�Ø—z‘z�Ø�
Ø“e ¡¨4£Ø Q¡™=�DØ˜A™�AÜ—y‘y DÓ(Ø%&˜
ð	 “e ¡¨4¥ð " B“Ø&˜ä—y‘y DÓ(¨J¸«OàŸ™ d§o¡o×&:Ñ&:¸4À!¸9Ó&EÔFØ™ð Ÿ™ d¡gÔ.Ø˜Q™™à—‘˜d™gÔ&Ø�Q‘�ð3 �eð4 ˆr   )r	   r
   )NÚ_)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r%   Ú__static_attributes__© r   r   r   r   #   s   † ñô$ò"õ,-r   r   N)r,   Únltk.tokenize.apir   Ú	nltk.utilr   r   r.   r   r   Ú<module>r1      s    ðñõ. )Ý ôY�:õ Yr   