How to use the pythainlp.__file__ function in pythainlp

To help you get started, we’ve selected a few pythainlp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyThaiNLP / pythainlp / pythainlp / tokenize / thai.py View on Github external
# -*- 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():
github PyThaiNLP / pythainlp / pythainlp / corpus / thaiword.py View on Github external
# -*- 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
github PyThaiNLP / pythainlp / pythainlp / tools / path.py View on Github external
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__)
github PyThaiNLP / pythainlp / pythainlp / corpus / thaisyllable.py View on Github external
# -*- 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
github PyThaiNLP / pythainlp / pythainlp / corpus / pos.py View on Github external
# -*- 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
github PyThaiNLP / pythainlp / pythainlp / corpus / newthaiword.py View on Github external
# -*- 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