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
2 changes: 1 addition & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'

group = 'kr.co.shineware.nlp.pykomoran'
version = '0.1.0'
version = '0.1.6'
sourceCompatibility = '1.8'

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class KomoranEntryPoint {
public void KomoranEntryPoint() {
}


/**
* 내부 <code>Komoran</code> 객체를 <code>modelPath</code>로 초기화합니다.
*
Expand All @@ -42,6 +43,13 @@ public void KomoranEntryPoint() {
* @see kr.co.shineware.nlp.komoran.core.Komoran
*/
public void init(String modelPath) {
// USING DEFAULT MODEL
if ("STABLE".equals(modelPath) || "EXP".equals(modelPath)) {
this.initByModelName(modelPath);
return;
}

// CHECK MODEL PATH
if (!new File(modelPath).exists()) {
return;
}
Expand All @@ -55,6 +63,7 @@ public void init(String modelPath) {
}
}


/**
* 내부 <code>Komoran</code> 객체가 초기화되었는지 확인합니다.
*
Expand All @@ -69,9 +78,10 @@ public boolean isInitialized() {
return false;
}


/**
* 내부 <code>Komoran</code> 객체를 기본 <code>modelType</code> 초기화합니다.
* <code>modelType</code> KOMORAN의 DEFAULT_MODEL 타입입니다.
* <code>modelType</code> KOMORAN의 DEFAULT_MODEL 타입입니다.
*
* @param modelType DEFAULT_MODEL 종류
* @see kr.co.shineware.nlp.komoran.core.Komoran
Expand All @@ -80,6 +90,28 @@ public void initByModel(DEFAULT_MODEL modelType) {
komoran = new Komoran(modelType);
}


/**
* 내부 <code>Komoran</code> 객체를 기본 <code>modelTypeName</code> 초기화합니다.
* <code>modelTypeName</code>은 KOMORAN의 DEFAULT_MODEL의 이름입니다.
*
* @param modelTypeName DEFAULT_MODEL의 이름
* @see kr.co.shineware.nlp.komoran.core.Komoran
*/
public void initByModelName(String modelTypeName) {
switch (modelTypeName) {
case "STABLE":
komoran = new Komoran(DEFAULT_MODEL.LIGHT);
break;
case "EXP":
komoran = new Komoran(DEFAULT_MODEL.FULL);
break;
default:
// TODO: throw ModelNotFoundException
}
}


/**
* 내부 <code>Komoran</code> 객체에 사용자 사전을 적용합니다.
*
Expand All @@ -89,6 +121,7 @@ public void setUserDic(String userDicPath) {
komoran.setUserDic(userDicPath);
}


/**
* 내부 <code>Komoran</code> 객체에 기분석 사전을 적용합니다.
*
Expand All @@ -98,6 +131,7 @@ public void setFWDic(String fwDicPath) {
komoran.setFWDic(fwDicPath);
}


/**
* 내부 <code>Komoran</code> 객체에 주어진 sentence를 분석하여 내부 <code>KomoranResult</code> 객체에 저장합니다.
*
Expand All @@ -108,6 +142,7 @@ public void analyze(String sentence) {
result = komoran.analyze(sentence);
}


/**
* 내부 <code>KomoranResult</code> 객체로부터 명사류의 형태소만 반환받습니다.
*
Expand All @@ -118,6 +153,7 @@ public List<String> getNouns() {
return result.getNouns();
}


/**
* 내부 <code>KomoranResult</code> 객체로부터 주어진 품사의 형태소들만 반환받습니다.
*
Expand All @@ -129,6 +165,7 @@ public List<String> getMorphesByTags(List<String> targetPosCollection) {
return result.getMorphesByTags(targetPosCollection);
}


/**
* 내부 <code>KomoranResult</code> 객체로부터 PlainText 형태의 분석 결과를 반환받습니다.
*
Expand All @@ -139,6 +176,7 @@ public String getPlainText() {
return result.getPlainText();
}


/**
* 내부 <code>KomoranResult</code> 객체로부터 분석 결과를 <code>Token</code> 형태로 반환받습니다.
* Python에서 이용할 수 있도록 <code>Token</code> 객체는 Map 객체로 변환하여 제공합니다.
Expand All @@ -155,6 +193,7 @@ public List<Map<String, Object>> getTokenList() {
// @formatter:on
}


/**
* 내부 <code>KomoranResult</code> 객체로부터 분석 결과를 <code>Pair</code> 형태로 반환받습니다.
* Python에서 이용할 수 있도록 <code>Pair</code> 객체는 Map 객체로 변환하여 제공합니다.
Expand All @@ -171,6 +210,7 @@ public List<Map<String, String>> getList() {
// @formatter:on
}


/**
* <code>Token</code> 객체를 Python에서 이용할 수 있도록 각 Key를 이름으로 갖는 Map 객체로 변환합니다.
*
Expand All @@ -186,6 +226,7 @@ private Map<String, Object> convertTokenToMap(Token token) {
}};
}


/**
* <code>Pair</code> 객체를 Python에서 이용할 수 있도록 각 Key를 이름으로 갖는 Map 객체로 변환합니다.
*
Expand All @@ -199,6 +240,7 @@ private Map<String, String> convertPairToMap(Pair pair) {
}};
}


/**
* 직접 실행 시 Py4J의 GatewayServer를 실행합니다.
*
Expand Down
2 changes: 1 addition & 1 deletion python/PyKomoran/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, model_path, max_heap=1024):
elif model_path == 'EXP':
model_path = DEFAULT_MODEL['FULL']

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

self.pos_table = Pos()
Expand Down
2 changes: 1 addition & 1 deletion python/PyKomoran/jvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def init_jvm(max_heap=1024, jar_path="./libs"):

libraries = [
'{0}{1}KOMORAN-4e7b5ef.jar',
'{0}{1}KOMORANEntryPoint-0.1.0.jar',
'{0}{1}KOMORANEntryPoint-0.1.6.jar',
# '{0}{1}*'
]

Expand Down
Binary file removed python/PyKomoran/libs/KOMORANEntryPoint-0.1.0.jar
Binary file not shown.
Binary file added python/PyKomoran/libs/KOMORANEntryPoint-0.1.6.jar
Binary file not shown.
Binary file removed python/PyKomoran/models_full/irregular.model
Binary file not shown.
Binary file removed python/PyKomoran/models_full/observation.model
Binary file not shown.
45 changes: 0 additions & 45 deletions python/PyKomoran/models_full/pos.table

This file was deleted.

Binary file removed python/PyKomoran/models_full/transition.model
Binary file not shown.
Binary file removed python/PyKomoran/models_light/irregular.model
Binary file not shown.
Binary file removed python/PyKomoran/models_light/observation.model
Binary file not shown.
45 changes: 0 additions & 45 deletions python/PyKomoran/models_light/pos.table

This file was deleted.

Binary file removed python/PyKomoran/models_light/transition.model
Binary file not shown.
6 changes: 4 additions & 2 deletions python/PyKomoran/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ 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': '{0}{1}models_full'.format(base_path, os.sep),
# 'LIGHT': "{0}{1}models_light".format(base_path, os.sep)
'FULL': 'EXP',
'LIGHT': 'STABLE'
}

def __getitem__(self, model):
Expand Down