Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

변경된 기본 모델명을 코드에 반영 #43

Merged
merged 1 commit into from
May 4, 2019
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
13 changes: 4 additions & 9 deletions python/PyKomoran/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class Komoran:
max_heap (int): JVM의 Max Heap Size (기본값: ``1024``, 단위: ``MB``)

Examples:
기본 모델( ``DEFAULT_MODEL['FULL']`` , ``DEFAULT_MODEL['LIGHT']`` ) 외에 사용자가 직접 생성한 모델이 위치하는
기본 모델( ``STABLE`` , ``EXP`` ) 외에 사용자가 직접 생성한 모델이 위치하는
``절대 경로`` 를 이용하여 Komoran 객체를 생성할 수 있습니다.

>>> # 기본으로 제공하는 LIGHT 모델로 Komoran 객체를 생성합니다.
>>> komoran = Komoran(DEFAULT_MODEL['LIGHT'])
>>> komoran = Komoran("STABLE")
>>> # 기본으로 제공하는 FULL 모델로 Komoran 객체를 생성합니다.
>>> komoran = Komoran(DEFAULT_MODEL['FULL'])
>>> komoran = Komoran("EXP")
>>> # 사용자가 미리 생성 모델로 Komoran 객체를 생성합니다.
>>> komoran_user = Komoran("/some/where/path/Komoran/Model")

Expand All @@ -43,11 +43,6 @@ def __init__(self, model_path, max_heap=1024):
if max_heap <= 0:
raise KomoranError("Heap size for JVM is too small!")

if model_path == 'STABLE':
model_path = DEFAULT_MODEL['LIGHT']
elif model_path == 'EXP':
model_path = DEFAULT_MODEL['FULL']

if not model_path in ('STABLE', 'EXP') and not os.path.exists(model_path):
raise KomoranError("model does NOT exist!")

Expand Down Expand Up @@ -295,7 +290,7 @@ def pos(self, sentence, flatten=True):


if __name__ == '__main__':
komoran = Komoran(DEFAULT_MODEL['FULL'])
komoran = Komoran("EXP")
str_to_analyze = "① 대한민국은 민주공화국이다. ② 대한민국의 주권은 국민에게 있고, 모든 권력은 국민으로부터 나온다."

print(komoran.get_nouns(str_to_analyze))
Expand Down
39 changes: 33 additions & 6 deletions python/PyKomoran/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,35 @@
komoran = None


def test_to_init_Komoran():
def test_to_init_Komoran_default_stable():
"""
Core Test: init Komoran with default model (models_light)
Core Test: init Komoran with default model (STABLE)
:return:
"""
global komoran

komoran = Komoran("STABLE")

assert komoran is not None
assert komoran._komoran.isInitialized()


def test_to_init_Komoran_default_exp():
"""
Core Test: init Komoran with default model (EXP)
:return:
"""
global komoran

komoran = Komoran("EXP")

assert komoran is not None
assert komoran._komoran.isInitialized()


def test_to_init_Komoran_default_stable_old_way():
"""
Core Test: init Komoran with default model (STABLE)
:return:
"""
global komoran
Expand All @@ -22,9 +48,9 @@ def test_to_init_Komoran():
assert komoran._komoran.isInitialized()


def test_to_init_Komoran():
def test_to_init_Komoran_default_exp_old_way():
"""
Core Test: init Komoran with default model (models_full)
Core Test: init Komoran with default model (EXP)
:return:
"""
global komoran
Expand All @@ -35,6 +61,7 @@ def test_to_init_Komoran():
assert komoran._komoran.isInitialized()



def test_to_analyze_get_nouns():
"""
Core Test: analyze using get_nouns()
Expand Down Expand Up @@ -322,7 +349,7 @@ def test_to_set_user_dic():
global komoran

if komoran is None:
komoran = Komoran(DEFAULT_MODEL['FULL'])
komoran = Komoran("EXP")

tokens = komoran.get_token_list("테스트 단어")

Expand Down Expand Up @@ -373,7 +400,7 @@ def test_to_set_fw_dic():
global komoran

if komoran is None:
komoran = Komoran(DEFAULT_MODEL['LIGHT'])
komoran = Komoran("STABLE")

tokens = komoran.get_token_list("눈이 감겼다")

Expand Down
2 changes: 0 additions & 2 deletions python/PyKomoran/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ def __init__(self):
base_path = os.path.dirname(os.path.realpath(__file__))

self._models = {
# 'FULL': '{0}{1}models_full'.format(base_path, os.sep),
# 'LIGHT': "{0}{1}models_light".format(base_path, os.sep)
'FULL': 'EXP',
'LIGHT': 'STABLE'
}
Expand Down