KomoranEntryPoint

public class KomoranEntryPoint

KOMORAN을 Wrapping하는 Class로, Py4J에 의해 불리는 Java-side의 EntryPoint입니다. 직접 실행 시 main 메소드에서 Py4J의 GatewayServer를 생성합니다.

사용법은 아래와 같습니다.

KomoranEntryPoint kep = new KomoranEntryPoint();
kep.init(MODEL_PATH);
Author:9bow

See also: kr.co.shineware.nlp.komoran.core.Komoran, py4j.GatewayServer

Methods

KomoranEntryPoint

public void KomoranEntryPoint()

analyze

public void analyze(String sentence)

내부 Komoran 객체에 주어진 sentence를 분석하여 내부 KomoranResult 객체에 저장합니다.

Parameters:
  • sentence – 분석할 문장

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

getList

public List<Map<String, String>> getList()

내부 KomoranResult 객체로부터 분석 결과를 Pair 형태로 반환받습니다. Python에서 이용할 수 있도록 Pair 객체는 Map 객체로 변환하여 제공합니다.

Returns:형태소 분석 결과의 Map(Pair) List

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

getMorphesByTags

public List<String> getMorphesByTags(List<String> targetPosCollection)

내부 KomoranResult 객체로부터 주어진 품사의 형태소들만 반환받습니다.

Parameters:
  • targetPosCollection – 품사 List
Returns:

주어진 형태소들에 해당하는 형태소 List

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

getNouns

public List<String> getNouns()

내부 KomoranResult 객체로부터 명사류의 형태소만 반환받습니다.

Returns:분석 결과 중, 명사류의 형태소 List

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

getPlainText

public String getPlainText()

내부 KomoranResult 객체로부터 PlainText 형태의 분석 결과를 반환받습니다.

Returns:전체 형태소 분석 결과의 PlainText

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

getTokenList

public List<Map<String, Object>> getTokenList()

내부 KomoranResult 객체로부터 분석 결과를 Token 형태로 반환받습니다. Python에서 이용할 수 있도록 Token 객체는 Map 객체로 변환하여 제공합니다.

Returns:형태소 분석 결과의 Map(Token) List

See also: kr.co.shineware.nlp.komoran.model.KomoranResult

init

public void init(String modelPath)

내부 Komoran 객체를 modelPath로 초기화합니다.

Parameters:
  • modelPath – 모델이 위치한 절대 경로
Throws:
  • FileNotFoundException – modelPath에 모델이 존재하지 않을 시 Exception 발생

See also: kr.co.shineware.nlp.komoran.core.Komoran

initByModel

public void initByModel(DEFAULT_MODEL modelType)

내부 Komoran 객체를 기본 modelType 초기화합니다. modelType은 KOMORAN의 DEFAULT_MODEL 타입입니다.

Parameters:
  • modelType – DEFAULT_MODEL 종류

See also: kr.co.shineware.nlp.komoran.core.Komoran

initByModelName

public void initByModelName(String modelTypeName)

내부 Komoran 객체를 기본 modelTypeName 초기화합니다. modelTypeName은 KOMORAN의 DEFAULT_MODEL의 이름입니다.

Parameters:
  • modelTypeName – DEFAULT_MODEL의 이름

See also: kr.co.shineware.nlp.komoran.core.Komoran

isInitialized

public boolean isInitialized()

내부 Komoran 객체가 초기화되었는지 확인합니다.

Returns:초기화 여부 (boolean)

See also: kr.co.shineware.nlp.komoran.core.Komoran

main

public static void main(String[] args)

직접 실행 시 Py4J의 GatewayServer를 실행합니다.

Parameters:
  • args

See also: py4j.GatewayServer

setFWDic

public void setFWDic(String fwDicPath)

내부 Komoran 객체에 기분석 사전을 적용합니다.

Parameters:
  • fwDicPath – 기분석 사전이 위치한 절대 경로

setUserDic

public void setUserDic(String userDicPath)

내부 Komoran 객체에 사용자 사전을 적용합니다.

Parameters:
  • userDicPath – 사용자 사전이 위치한 절대 경로