pythainlp.morpheme
The pythainlp.morpheme module is collect functions for morpheme analysis, word formation and more for Thai language.
- pythainlp.morpheme.nighit(w1: str, w2: str) str[source]
Create a new word using Nighit (นิคหิต or ํ).
Nighit is the niggahita in Thai, used to form new words from Pali roots. This function applies a simple rule to combine two Thai words derived from Pali.
Reference: https://www.trueplookpanya.com/learning/detail/1180
- Parameters:
- Returns:
combined Thai word
- Return type:
- Example:
>>> from pythainlp.morpheme import nighit >>> nighit("สํ", "คีต") 'สังคีต' >>> nighit("สํ", "จร") 'สัญจร' >>> nighit("สํ", "ฐาน") 'สัณฐาน' >>> nighit("สํ", "นิษฐาน") 'สันนิษฐาน' >>> nighit("สํ", "ปทา") 'สัมปทา' >>> nighit("สํ", "โยค") 'สังโยค'
- pythainlp.morpheme.is_native_thai(word: str) bool[source]
Check if a word is an “native Thai word” (Thai: “คำไทยแท้”) This function is based on a simple heuristic algorithm and cannot be entirely reliable.
- Parameters:
word (str) – word
- Returns:
True or False
- Return type:
- Example:
>>> from pythainlp.morpheme import is_native_thai >>> is_native_thai("Avocado") False >>> is_native_thai("มะม่วง") True >>> is_native_thai("ตะวัน") True >>> is_native_thai("สามารถ") False >>> is_native_thai("อิสริยาภรณ์") False
The is_native_thai function is a language detection tool that identifies whether text is predominantly in the Thai language or not. It aids in language identification and text categorization tasks.