Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
import os
import pythainlp
TEMPLATES_DIR = os.path.join(os.path.dirname(pythainlp.__file__), "corpus")
def fileload(name1):
return os.path.join(TEMPLATES_DIR, name1)
def data():
"""
โหลดรายการคำศัพท์ภาษาไทย (ตัวเก่า)
"""
with open(fileload("thaiword.txt"), "r", encoding="utf-8-sig") as f:
lines = f.read().splitlines()
return lines
def newdata():
# -*- coding: utf-8 -*-
from __future__ import absolute_import,unicode_literals
import os
import codecs
import pythainlp
templates_dir = os.path.join(os.path.dirname(pythainlp.__file__), 'corpus')
def get_data(dict_fname = 'thaiword.txt'):
template_file = os.path.join(templates_dir, dict_fname)
with codecs.open(template_file, 'r',encoding='utf8') as f:
lines = f.read().splitlines()
return lines
def get_pythainlp_path() -> str:
"""
This function returns full path of PyThaiNLP code
:return: full path of :mod:`pythainlp` code
:rtype: str
:Example:
::
from pythainlp.tools import get_pythainlp_path
get_pythainlp_path()
# output: '/usr/local/lib/python3.6/dist-packages/pythainlp'
"""
return os.path.dirname(pythainlp.__file__)
# -*- coding: utf-8 -*-
import os
import pythainlp
TEMPLATES_DIR = os.path.join(os.path.dirname(pythainlp.__file__), "corpus")
TEMPLATE_FILE = os.path.join(TEMPLATES_DIR, "thai_syllable.txt")
def get_data():
with open(TEMPLATE_FILE, "r", encoding="utf8") as f:
lines = f.read().splitlines()
return lines
# -*- coding: utf-8 -*-
import json
import os
import pythainlp
TEMPLATES_DIR = os.path.join(os.path.dirname(pythainlp.__file__), "corpus")
TEMPLATE_FILE = os.path.join(TEMPLATES_DIR, "pos_th.json")
def get_data():
with open(TEMPLATE_FILE, encoding="utf-8-sig") as f:
model = json.load(f)
return model
# -*- coding: utf-8 -*-
import os
import pythainlp
TEMPLATES_DIR = os.path.join(os.path.dirname(pythainlp.__file__), "corpus")
TEMPLATE_FILE = os.path.join(TEMPLATES_DIR, "new-thaidict.txt")
def get_data():
with open(TEMPLATE_FILE, "r", encoding="utf8") as f:
lines = f.read().splitlines()
return lines