|
2 | 2 |
|
3 | 3 | pythainlp.generate |
4 | 4 | ================== |
5 | | -The :class:`pythainlp.generate` module is a powerful tool for generating Thai text using PyThaiNLP. It includes several classes and functions that enable users to create text based on various language models and n-gram models. |
6 | 5 |
|
7 | | -Modules |
8 | | -------- |
9 | | - |
10 | | -Unigram |
11 | | -~~~~~~~ |
12 | | -.. autoclass:: Unigram |
13 | | - :members: |
| 6 | +The :mod:`pythainlp.generate` module provides classes and functions for generating Thai text using n-gram and neural language models. |
14 | 7 |
|
15 | | -The :class:`Unigram` class provides functionality for generating text based on unigram language models. Unigrams are single words or tokens, and this class allows you to create text by selecting words probabilistically based on their frequencies in the training data. |
| 8 | +N-gram generators |
| 9 | +----------------- |
16 | 10 |
|
17 | | -Bigram |
18 | | -~~~~~~ |
19 | | -.. autoclass:: Bigram |
| 11 | +.. autoclass:: pythainlp.generate.Unigram |
20 | 12 | :members: |
21 | 13 |
|
22 | | -The :class:`Bigram` class is designed for generating text using bigram language models. Bigrams are sequences of two words, and this class enables you to generate text by predicting the next word based on the previous word's probability. |
| 14 | +.. autoclass:: pythainlp.generate.Bigram |
| 15 | + :members: |
23 | 16 |
|
24 | | -Trigram |
25 | | -~~~~~~~ |
26 | | -.. autoclass:: Trigram |
| 17 | +.. autoclass:: pythainlp.generate.Trigram |
27 | 18 | :members: |
28 | 19 |
|
29 | | -The :class:`Trigram` class extends text generation to trigram language models. Trigrams consist of three consecutive words, and this class facilitates the creation of text by predicting the next word based on the two preceding words' probabilities. |
| 20 | +Thai2fit helper |
| 21 | +--------------- |
30 | 22 |
|
31 | | -pythainlp.generate.thai2fit.gen_sentence |
32 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
33 | 23 | .. autofunction:: pythainlp.generate.thai2fit.gen_sentence |
34 | 24 | :noindex: |
35 | 25 |
|
36 | | -The function :func:`pythainlp.generate.thai2fit.gen_sentence` offers a convenient way to generate sentences using the Thai2Vec language model. It takes a seed text as input and generates a coherent sentence based on the provided context. |
| 26 | +WangChanLM |
| 27 | +---------- |
37 | 28 |
|
38 | | -pythainlp.generate.wangchanglm.WangChanGLM |
39 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
40 | 29 | .. autoclass:: pythainlp.generate.wangchanglm.WangChanGLM |
41 | 30 | :members: |
42 | 31 |
|
43 | | -The :class:`WangChanGLM` class is a part of the `pythainlp.generate.wangchanglm` module, offering text generation capabilities. It includes methods for creating text using the WangChanGLM language model. |
44 | | - |
45 | 32 | Usage |
46 | | -~~~~~ |
47 | | - |
48 | | -To use the text generation capabilities provided by the `pythainlp.generate` module, follow these steps: |
| 33 | +----- |
49 | 34 |
|
50 | | -1. Select the appropriate class or function based on the type of language model you want to use (Unigram, Bigram, Trigram, Thai2Vec, or WangChanGLM). |
51 | | - |
52 | | -2. Initialize the selected class or use the function with the necessary parameters. |
53 | | - |
54 | | -3. Call the appropriate methods to generate text based on the chosen model. |
55 | | - |
56 | | -4. Utilize the generated text for various applications, such as chatbots, content generation, and more. |
| 35 | +Choose the generator class or function for the model you want, initialize it with appropriate parameters, and call its generation methods. Generated text can be used for chatbots, content generation, or data augmentation. |
57 | 36 |
|
58 | 37 | Example |
59 | | -~~~~~~~ |
60 | | - |
61 | | -Here's a simple example of how to generate text using the `Unigram` class: |
| 38 | +------- |
62 | 39 |
|
63 | 40 | :: |
64 | 41 | from pythainlp.generate import Unigram |
65 | | - |
66 | | - # Initialize the Unigram model |
| 42 | + |
67 | 43 | unigram = Unigram() |
68 | | - |
69 | | - # Generate a sentence |
70 | 44 | sentence = unigram.gen_sentence("สวัสดีครับ") |
71 | | - |
72 | 45 | print(sentence) |
0 commit comments