Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/corpus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Modules
.. autofunction:: provinces
.. autofunction:: thai_stopwords
.. autofunction:: thai_words
.. autofunction:: thai_orst_words
.. autofunction:: thai_syllables
.. autofunction:: thai_negations
.. autofunction:: thai_family_names
Expand Down
2 changes: 2 additions & 0 deletions pythainlp/corpus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"thai_stopwords",
"thai_syllables",
"thai_words",
"thai_orst_words",
"path_pythainlp_corpus",
"get_path_folder_corpus",
]
Expand Down Expand Up @@ -110,4 +111,5 @@ def corpus_db_path() -> str:
thai_stopwords,
thai_syllables,
thai_words,
thai_orst_words,
)
18 changes: 18 additions & 0 deletions pythainlp/corpus/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
_THAI_MALE_NAMES = set()
_THAI_MALE_NAMES_FILENAME = "person_names_male_th.txt"

_THAI_ORST_WORDS = set()


def countries() -> FrozenSet[str]:
"""
Expand Down Expand Up @@ -153,6 +155,22 @@ def thai_words() -> FrozenSet[str]:
return _THAI_WORDS


def thai_orst_words() -> FrozenSet[str]:
"""
Return a frozenset of Thai words from Royal Society of Thailand
\n(See: `dev/pythainlp/corpus/thai_orst_words.txt\
<https://github.com/PyThaiNLP/pythainlp/blob/dev/pythainlp/corpus/thai_orst_words>`_)

:return: :class:`frozenset` containing words in Thai language.
:rtype: :class:`frozenset`
"""
global _THAI_ORST_WORDS
if not _THAI_ORST_WORDS:
_THAI_ORST_WORDS = get_corpus("thai_orst_words.txt")

return _THAI_ORST_WORDS


def thai_stopwords() -> FrozenSet[str]:
"""
Return a frozenset of Thai stopwords such as "มี", "ไป", "ไง", "ขณะ",
Expand Down
Loading