
    \j,                     F    d dl mZmZmZmZ ddlmZ dZdZ G d de      Z	y)	    )ListOptionalSequencecast   )BaseProviderTlac                      e Zd ZdZdZdZ	 	 ddee   deee      de	e   fdZ
	 	 	 	 dd	edee	e      dee   d
ede	e   f
dZddee   deee      defdZ	 ddededeee      defdZdd	edeee      de	e   fdZ	 ddededeee      defdZdd	edeee      de	e   fdZddedeee      defdZ	 ddededeee      de	e   fdZy) Providera  Implement default lorem provider for Faker.

    .. important::
       The default locale of the lorem provider is ``la``. When using a locale
       without a localized lorem provider, the ``la`` lorem provider will be
       used, so generated words will be in pseudo-Latin. The locale used for
       the standard provider docs was ``en_US``, and ``en_US`` has a localized
       lorem provider which is why the samples here show words in American
       English.
     .Npart_of_speechext_word_listreturnc                     ||}t        |      S |r6|| j                   vrt        | d      | j                   |   }t        |      S | j                  }t        |      S )a$  Get list of words.

        ``ext_word_list`` is a parameter that allows the user to provide a list
        of words to be used instead of the built-in word list. If ``ext_word_list``
        is provided, then the value of ``part_of_speech`` is ignored.

        ``part_of_speech`` is a parameter that defines to what part of speech
        the returned word belongs. If ``ext_word_list`` is not ``None``, then
        ``part_of_speech`` is ignored. If the value of ``part_of_speech`` does
        not correspond to an existent part of speech according to the set locale,
        then an exception is raised.

        :sample: part_of_speech="abc", ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: part_of_speech="abc"
        :sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']

        .. warning::
            Depending on the length of a locale provider's built-in word list or
            on the length of ``ext_word_list`` if provided, a large ``nb`` can
            exhaust said lists if ``unique`` is ``True``, raising an exception.
        z' is not recognized as a part of speech.)parts_of_speech
ValueError	word_listlistselfr   r   r   s       H/root/env/lib/python3.12/site-packages/faker/providers/lorem/__init__.pyget_words_listzProvider.get_words_list   ss    6 $%I I T%9%99 N#33Z![\\ 00@	 I II    nbuniquec                     | j                  ||      }|r*t        t        t           | j	                  ||            }|S t        t        t           | j                  ||            }|S )a  Generate a tuple of words.

        The ``nb`` argument controls the number of words in the resulting list,
        and if ``ext_word_list`` is provided, words from that list will be used
        instead of those from the locale provider's built-in word list.

        if ``word_list`` is not provided, the method will use a default value of None,
        which will result in the method calling the ``get_words_list`` method to get the
        word list. If ``word_list`` is provided, the method will use the provided list.

        If ``unique`` is ``True``, this method will return a list containing
        unique words. Under the hood, |random_sample| will be used for sampling
        without replacement. If ``unique`` is ``False``, |random_choices| is
        used instead, and the list returned may contain duplicates.

        :sample:
        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb=4, ext_word_list=['abc', 'def', 'ghi', 'jkl'], unique=True
        )r   r   )length)r   r   r   strrandom_samplerandom_choices)r   r   r   r   r   r   unique_samplessampless           r   wordszProvider.wordsA   si    8 ''~Ub'c	!$s)T-?-?	RT-?-UVN!!tCy$"5"5i"5"KLr   c                 P    | j                  ||      }| j                  d|      d   S )zGenerate a word.

        This method uses |words| under the hood with the ``nb`` argument set to
        ``1`` to generate the result.

        :sample:
        :sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']
           r   )r   r$   r   s       r   wordzProvider.worde   s,     ''F	zz!Y'**r   nb_wordsvariable_nb_wordsc                    |dk  ry|r| j                  |d      }| j                  |      }t        | j                  ||            }|d   j	                         |d<   | j
                  j                  |      | j                  z   S )a  Generate a sentence.

        The ``nb_words`` argument controls how many words the sentence will
        contain, and setting ``variable_nb_words`` to ``False`` will generate
        the exact amount, while setting it to ``True`` (default) will generate
        a random amount (+/-40%, minimum of 1) using |randomize_nb_elements|.

        Under the hood, |words| is used to generate the words, so the argument
        ``ext_word_list`` works in the same way here as it would in that method.

        :sample: nb_words=10
        :sample: nb_words=10, variable_nb_words=False
        :sample: nb_words=10, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb_words=10, variable_nb_words=True,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r    r&   minr   )r   r   )randomize_nb_elementsr   r   r$   titleword_connectorjoinsentence_punctuation)r   r(   r)   r   r   r$   s         r   sentencezProvider.sentencer   s    & q=11(1BH''m'D	TZZ89ZEF8>>#a""''.1J1JJJr   c                 `    t        d|      D cg c]  }| j                  |       c}S c c}w )a  Generate a list of sentences.

        This method uses |sentence| under the hood to generate sentences, and
        the ``nb`` argument controls exactly how many sentences the list will
        contain. The ``ext_word_list`` argument works in exactly the same way
        as well.

        :sample:
        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r   r.   )ranger4   r   r   r   _s       r   	sentenceszProvider.sentences   s+     EJ!RLQqM:QQQ   +nb_sentencesvariable_nb_sentencesc                     |dk  ry|r| j                  |d      }| j                  j                  | j                  ||            }|S )a@  Generate a paragraph.

        The ``nb_sentences`` argument controls how many sentences the paragraph
        will contain, and setting ``variable_nb_sentences`` to ``False`` will
        generate the exact amount, while setting it to ``True`` (default) will
        generate a random amount (+/-40%, minimum of 1) using
        |randomize_nb_elements|.

        Under the hood, |sentences| is used to generate the sentences, so the
        argument ``ext_word_list`` works in the same way here as it would in
        that method.

        :sample: nb_sentences=5
        :sample: nb_sentences=5, variable_nb_sentences=False
        :sample: nb_sentences=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb_sentences=5, variable_nb_sentences=False,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r   r+   r&   r,   r.   )r/   r1   r2   r9   )r   r;   r<   r   paras        r   	paragraphzProvider.paragraph   sP    * 1 55l5JL""''|S`(abr   c                 `    t        d|      D cg c]  }| j                  |       c}S c c}w )a~  Generate a list of paragraphs.

        This method uses |paragraph| under the hood to generate paragraphs, and
        the ``nb`` argument controls exactly how many sentences the list will
        contain. The ``ext_word_list`` argument works in exactly the same way
        as well.

        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r   r.   )r6   r?   r7   s       r   
paragraphszProvider.paragraphs   s+     FK1b\R];RRRr:   max_nb_charsc                 2   g }|dk  rt        d      |dk  r|sbd}||k  rH|r| j                  nd| j                  |      z   }|j                  |       |t	        |      z  }||k  rH|j                          |sb|d   d   j                         |d   dd z   |d<   t	        |      dz
  }||xx   | j                  z  cc<   n|d	k  re|sd}||k  rH|r| j                  nd| j                  |      z   }|j                  |       |t	        |      z  }||k  rH|j                          |sbnZ|sXd}||k  r>|rd
nd| j                  |      z   }|j                  |       |t	        |      z  }||k  r>|j                          |sXdj                  |      S )a"  Generate a text string.

        The ``max_nb_chars`` argument controls the approximate number of
        characters the text string will have, and depending on its value, this
        method may use either |words|, |sentences|, or |paragraphs| for text
        generation. The ``ext_word_list`` argument works in exactly the same way
        it would in any of those methods.

        :sample: max_nb_chars=20
        :sample: max_nb_chars=80
        :sample: max_nb_chars=160
        :sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']
           z6text() can only generate text of at least 5 characters   r   r+   r.   r&   Nd   
)r   r1   r'   appendlenpopupperr3   r4   r?   r2   )	r   rB   r   textsizer'   
last_indexr4   r?   s	            r   rL   zProvider.text   s    !UVV" \)37D//R499[h9CiiDKK%CI%D \) 
  1gaj&&(4712;6DGTQJ 9 99C \)7; 3 3t}}cp}GqqHKK)CM)D \) 
   \))-2Vc9d dIKK	*C	N*D \) 
  wwt}r   nb_textsc                 `    t        d|      D cg c]  }| j                  ||       c}S c c}w )a   Generate a list of text strings.

        The ``nb_texts`` argument controls how many text strings the list will
        contain, and this method uses |text| under the hood for text generation,
        so the two remaining arguments, ``max_nb_chars`` and ``ext_word_list``
        will work in exactly the same way as well.

        :sample: nb_texts=5
        :sample: nb_texts=5, max_nb_chars=50
        :sample: nb_texts=5, max_nb_chars=50,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r   )r6   rL   )r   rO   rB   r   r8   s        r   textszProvider.texts  s,     AFa@RS1		,6SSSr:   )NN)   NNF)   TN)rR   N)rR   TN)   N)rR   rT   N)__name__
__module____qualname____doc__r1   r3   r   r   r   r   r   intboolr$   r'   r4   r9   r?   rA   rL   rQ    r   r   r   r      s   	 N )-15% %  .% 
c	%R -1(,""  S	*" !	"
 " 
c"H+8C= +QYZ]Q^H_ +kn + koKK48KPXYabeYfPgK	K>RC RHXc]4K RW[\_W` R sw<@X`aijmanXo	>SS SXhsm5L SX\]`Xa S7 78HSM;R 7^a 7t dhTT/2TIQRZ[^R_I`T	cTr   r   N)
typingr   r   r   r   r+   r   	localizeddefault_localer   r[   r   r   <module>r_      s*    1 1 	 HT| HTr   