Locale la¶
faker.providers.lorem
¶
- class faker.providers.lorem.la.Provider(generator: Any)¶
Bases:
Provider
Implement lorem provider for
la
locale.- paragraph(nb_sentences: int = 3, variable_nb_sentences: bool = True, ext_word_list: Sequence[str] | None = None) str ¶
Generate a paragraph.
The
nb_sentences
argument controls how many sentences the paragraph will contain, and settingvariable_nb_sentences
toFalse
will generate the exact amount, while setting it toTrue
(default) will generate a random amount (+/-40%, minimum of 1) usingrandomize_nb_elements()
.Under the hood,
sentences()
is used to generate the sentences, so the argumentext_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’]
- paragraphs(nb: int = 3, ext_word_list: Sequence[str] | None = None) List[str] ¶
Generate a list of paragraphs.
This method uses
paragraph()
under the hood to generate paragraphs, and thenb
argument controls exactly how many sentences the list will contain. Theext_word_list
argument works in exactly the same way as well.- Sample:
nb=5
- Sample:
nb=5, ext_word_list=[‘abc’, ‘def’, ‘ghi’, ‘jkl’]
- sentence(nb_words: int = 6, variable_nb_words: bool = True, ext_word_list: Sequence[str] | None = None) str ¶
Generate a sentence.
The
nb_words
argument controls how many words the sentence will contain, and settingvariable_nb_words
toFalse
will generate the exact amount, while setting it toTrue
(default) will generate a random amount (+/-40%, minimum of 1) usingrandomize_nb_elements()
.Under the hood,
words()
is used to generate the words, so the argumentext_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’]
- sentences(nb: int = 3, ext_word_list: Sequence[str] | None = None) List[str] ¶
Generate a list of sentences.
This method uses
sentence()
under the hood to generate sentences, and thenb
argument controls exactly how many sentences the list will contain. Theext_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’]
- text(max_nb_chars: int = 200, ext_word_list: Sequence[str] | None = None) str ¶
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 eitherwords()
,sentences()
, orparagraphs()
for text generation. Theext_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’]
- texts(nb_texts: int = 3, max_nb_chars: int = 200, ext_word_list: Sequence[str] | None = None) List[str] ¶
Generate a list of text strings.
The
nb_texts
argument controls how many text strings the list will contain, and this method usestext()
under the hood for text generation, so the two remaining arguments,max_nb_chars
andext_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’]
- word(part_of_speech: str | None = None, ext_word_list: Sequence[str] | None = None) str ¶
Generate a word.
This method uses
words()
under the hood with thenb
argument set to1
to generate the result.- Sample:
- Sample:
ext_word_list=[‘abc’, ‘def’, ‘ghi’, ‘jkl’]
- words(nb: int = 3, part_of_speech: str | None = None, ext_word_list: Sequence[str] | None = None, unique: bool = False) List[str] ¶
Generate a tuple of words.
The
nb
argument controls the number of words in the resulting list, and ifext_word_list
is provided, words from that list will be used instead of those from the locale provider’s built-in word list.If
unique
isTrue
, this method will return a list containing unique words. Under the hood,random_sample()
will be used for sampling without replacement. Ifunique
isFalse
,random_choices()
is used instead, and the list returned may contain duplicates.part_of_speech
is a parameter that defines to what part of speech the returned word belongs. Ifext_word_list
is notNone
, thenpart_of_speech
is ignored. If the value ofpart_of_speech
does not correspond to an existent part of speech according to the set locale, then an exception is raised.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 largenb
can exhaust said lists ifunique
isTrue
, raising an exception.- 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