Locale la¶
faker.providers.lorem¶
-
class
faker.providers.lorem.la.Provider(generator)¶ Bases:
faker.providers.lorem.ProviderImplement lorem provider for
lalocale.-
paragraph(nb_sentences=3, variable_nb_sentences=True, ext_word_list=None)¶ Generate a paragraph.
The
nb_sentencesargument controls how many sentences the paragraph will contain, and settingvariable_nb_sentencestoFalsewill 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_listworks 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=3, ext_word_list=None)¶ Generate a list of paragraphs.
This method uses
paragraph()under the hood to generate paragraphs, and thenbargument controls exactly how many sentences the list will contain. Theext_word_listargument works in exactly the same way as well.Sample: nb=5 Sample: nb=5, ext_word_list=[‘abc’, ‘def’, ‘ghi’, ‘jkl’]
-
sentence(nb_words=6, variable_nb_words=True, ext_word_list=None)¶ Generate a sentence.
The
nb_wordsargument controls how many words the sentence will contain, and settingvariable_nb_wordstoFalsewill 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_listworks 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=3, ext_word_list=None)¶ Generate a list of sentences.
This method uses
sentence()under the hood to generate sentences, and thenbargument controls exactly how many sentences the list will contain. Theext_word_listargument 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=200, ext_word_list=None)¶ Generate a text string.
The
max_nb_charsargument 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_listargument 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=3, max_nb_chars=200, ext_word_list=None)¶ Generate a list of text strings.
The
nb_textsargument 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_charsandext_word_listwill 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(ext_word_list=None)¶ Generate a word.
This method uses
words()under the hood with thenbargument set to1to generate the result.Sample: Sample: ext_word_list=[‘abc’, ‘def’, ‘ghi’, ‘jkl’]
-
words(nb=3, ext_word_list=None, unique=False)¶ Generate a list of words.
The
nbargument controls the number of words in the resulting list, and ifext_word_listis provided, words from that list will be used instead of those from the locale provider’s built-in word list.If
uniqueisTrue, this method will return a list containing unique words. Under the hood,random_sample()will be used for sampling without replacement. IfuniqueisFalse,random_choices()is used instead, and the list returned may contain duplicates.Warning
Depending on the length of a locale provider’s built-in word list or on the length of
ext_word_listif provided, a largenbcan exhaust said lists ifuniqueisTrue, 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
-