faker.providers.lorem.th_TH

Package Contents

Classes

LoremProvider

Implement default lorem provider for Faker.

Provider

Implement lorem provider for th_TH locale.

class faker.providers.lorem.th_TH.LoremProvider(generator: Any)

Bases: faker.providers.BaseProvider

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.

word_connector = ' '
sentence_punctuation = '.'
words(nb: int = 3, part_of_speech: Optional[str] = None, ext_word_list: Optional[Sequence[str]] = 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 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.

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.

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.

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

word(part_of_speech: Optional[str] = None, ext_word_list: Optional[Sequence[str]] = 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’]

sentence(nb_words: int = 6, variable_nb_words: bool = True, ext_word_list: Optional[Sequence[str]] = 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: Optional[Sequence[str]] = 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’]

paragraph(nb_sentences: int = 3, variable_nb_sentences: bool = True, ext_word_list: Optional[Sequence[str]] = 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: Optional[Sequence[str]] = 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’]

text(max_nb_chars: int = 200, ext_word_list: Optional[Sequence[str]] = 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 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’]

texts(nb_texts: int = 3, max_nb_chars: int = 200, ext_word_list: Optional[Sequence[str]] = 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’]

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

Bases: faker.providers.lorem.Provider

Implement lorem provider for th_TH locale.

Word list is randomly drawn from the Thailand’s Ministry of Education, removing compound words and long words, adding common words (like prepositions) and few of regional words.

Sources:

word_connector = ''
sentence_punctuation = ' '
word_list = ('กตัญญู', 'กบ', 'กรดไหลย้อน', 'กรรมการ', 'กระจาย', 'กระถาง', 'กล', 'กล่อง', 'กล้า', 'กลาง',...
parts_of_speech: Dict[str, tuple]