Locale la

faker.providers.lorem

class faker.providers.lorem.la.Provider(generator: Any)

Bases: Provider

Implement lorem provider for la locale.

get_words_list(part_of_speech: str | None = None, ext_word_list: Sequence[str] | None = None) → List[str]

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.

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 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’]

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 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’]

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 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’]

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 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’]

text(max_nb_chars: int = 200, ext_word_list: Sequence[str] | None = None) → str

Generate a text string.

The max_nb_chars argument is an upper bound, not a target: the result will never be longer than max_nb_chars, but it can be substantially shorter. This is because the text is built from whole words, sentences, or paragraphs (depending on the value of max_nb_chars), and the last complete unit that would push the length past the limit is dropped. For example, max_nb_chars=200 regularly produces strings of 100-190 characters. Values below 5 raise a ValueError. The ext_word_list argument works in exactly the same way it would in words(), sentences(), or paragraphs().

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 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’]

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 the nb argument set to 1 to generate the result.

Sample:

Sample:

ext_word_list=[‘abc’, ‘def’, ‘ghi’, ‘jkl’]

words(nb: int = 3, ext_word_list: List[str] | None = None, part_of_speech: 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 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