pythainlp.generate
The pythainlp.generate
is Thai text generate with PyThaiNLP.
Modules
- class pythainlp.generate.Unigram(name: str = 'tnc')[source]
Text generator using Unigram
- Parameters:
name (str) – corpus name * tnc - Thai National Corpus (default) * ttc - Thai Textbook Corpus (TTC) * oscar - OSCAR Corpus
- gen_sentence(start_seq: str | None = None, N: int = 3, prob: float = 0.001, output_str: bool = True, duplicate: bool = False) List[str] | str [source]
- Parameters:
- Returns:
list words or str words
- Return type:
- Example:
from pythainlp.generate import Unigram gen = Unigram() gen.gen_sentence("แมว") # ouput: 'แมวเวลานะนั้น'
- class pythainlp.generate.Bigram(name: str = 'tnc')[source]
Text generator using Bigram
- Parameters:
name (str) – corpus name * tnc - Thai National Corpus (default)
- gen_sentence(start_seq: str | None = None, N: int = 4, prob: float = 0.001, output_str: bool = True, duplicate: bool = False) List[str] | str [source]
- Parameters:
- Returns:
list words or str words
- Return type:
- Example:
from pythainlp.generate import Bigram gen = Bigram() gen.gen_sentence("แมว") # ouput: 'แมวไม่ได้รับเชื้อมัน'
- class pythainlp.generate.Trigram(name: str = 'tnc')[source]
Text generator using Trigram
- Parameters:
name (str) – corpus name * tnc - Thai National Corpus (default)
- gen_sentence(start_seq: str | None = None, N: int = 4, prob: float = 0.001, output_str: bool = True, duplicate: bool = False) List[str] | str [source]
- Parameters:
- Returns:
list words or str words
- Return type:
- Example:
from pythainlp.generate import Trigram gen = Trigram() gen.gen_sentence() # ouput: 'ยังทำตัวเป็นเซิร์ฟเวอร์คือ'
- pythainlp.generate.thai2fit.gen_sentence(start_seq: str | None = None, N: int = 4, prob: float = 0.001, output_str: bool = True) List[str] | str [source]
Text generator using Thai2fit
- Parameters:
- Returns:
list words or str words
- Return type:
- Example:
from pythainlp.generate.thai2fit import gen_sentence gen_sentence() # output: 'แคทรียา อิงลิช (นักแสดง' gen_sentence("แมว") # output: 'แมว คุณหลวง '