Skip to content

Commit

Permalink
Update import
Browse files Browse the repository at this point in the history
  • Loading branch information
wannaphong committed Jan 31, 2021
1 parent 590e24d commit 3c4cef0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pythainlp/tag/pos_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def pos_tag(
return []

if engine == "perceptron":
from .perceptron import tag as tag_
from pythainlp.tag.perceptron import tag as tag_
else: # default, use "unigram" ("old") engine
from .unigram import tag as tag_
from pythainlp.tag.unigram import tag as tag_

word_tags = tag_(words, corpus=corpus)

Expand Down
24 changes: 12 additions & 12 deletions pythainlp/tokenize/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def clause_tokenize(doc: List[str]) -> List[List[str]]:
['และ', 'คุณ', 'เล่น', 'มือถือ'],
['ส่วน', 'น้อง', 'เขียน', 'โปรแกรม']]
"""
from .crfcls import segment
from pythainlp.tokenize.crfcls import segment

return segment(doc)

Expand Down Expand Up @@ -132,35 +132,35 @@ def word_tokenize(
segments = []

if engine == "newmm" or engine == "onecut":
from .newmm import segment
from pythainlp.tokenize.newmm import segment

segments = segment(text, custom_dict)
elif engine == "newmm-safe":
from .newmm import segment
from pythainlp.tokenize.newmm import segment

segments = segment(text, custom_dict, safe_mode=True)
elif engine == "attacut":
from .attacut import segment
from pythainlp.tokenize.attacut import segment

segments = segment(text)
elif engine == "longest":
from .longest import segment
from pythainlp.tokenize.longest import segment

segments = segment(text, custom_dict)
elif engine == "mm" or engine == "multi_cut":
from .multi_cut import segment
from pythainlp.tokenize.multi_cut import segment

segments = segment(text, custom_dict)
elif engine == "deepcut": # deepcut can optionally use dictionary
from .deepcut import segment
from pythainlp.tokenize.deepcut import segment

if custom_dict:
custom_dict = list(custom_dict)
segments = segment(text, custom_dict)
else:
segments = segment(text)
elif engine == "icu":
from .pyicu import segment
from pythainlp.tokenize.pyicu import segment

segments = segment(text)
else:
Expand Down Expand Up @@ -244,7 +244,7 @@ def sent_tokenize(
segments = []

if engine == "crfcut":
from .crfcut import segment
from pythainlp.tokenize.crfcut import segment

segments = segment(text)
elif engine == "whitespace":
Expand Down Expand Up @@ -325,9 +325,9 @@ def subword_tokenize(
return []

if engine == "tcc":
from .tcc import segment
from pythainlp.tokenize.tcc import segment
elif engine == "etcc":
from .etcc import segment
from pythainlp.tokenize.etcc import segment
else:
raise ValueError(
f"""Tokenizer \"{engine}\" not found.
Expand Down Expand Up @@ -394,7 +394,7 @@ def syllable_tokenize(
)
)
elif engine == "ssg":
from .ssg import segment
from pythainlp.tokenize.ssg import segment

segments = segment(text)
else:
Expand Down
2 changes: 1 addition & 1 deletion pythainlp/tokenize/newmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pythainlp.tokenize import DEFAULT_WORD_DICT_TRIE
from pythainlp.util import Trie

from .tcc import tcc_pos
from pythainlp.tokenize.tcc import tcc_pos

# match non-Thai tokens
_PAT_NONTHAI = re.compile(
Expand Down
10 changes: 5 additions & 5 deletions pythainlp/transliterate/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def romanize(text: str, engine: str = DEFAULT_ROMANIZE_ENGINE) -> str:
return ""

if engine == "thai2rom":
from .thai2rom import romanize
from pythainlp.transliterate.thai2rom import romanize
else: # use default engine "royin"
from .royin import romanize
from pythainlp.transliterate.royin import romanize

return romanize(text)

Expand Down Expand Up @@ -100,10 +100,10 @@ def transliterate(
return ""

if engine == "icu" or engine == "pyicu":
from .pyicu import transliterate
from pythainlp.transliterate.pyicu import transliterate
elif engine == "thaig2p":
from .thaig2p import transliterate
from pythainlp.transliterate.thaig2p import transliterate
else:
from .ipa import transliterate
from pythainlp.transliterate.ipa import transliterate

return transliterate(text)

0 comments on commit 3c4cef0

Please sign in to comment.