lemon-core
Version:
Lemon Serverless Micro-Service Platform
103 lines (102 loc) • 3.5 kB
TypeScript
/**
* `hangul-service.ts`
* - common service for handling hangul
*
*
* @author Tim Hong <tim@lemoncloud.io>
* @date 2020-07-27 initial version
*
* @copyright (C) 2019 LemonCloud Co Ltd. - All Rights Reserved.
*/
/**
* class `HangulService`
* - transform hangul to qwerty type.
*/
export declare class HangulService {
/** 1.Initial consonants (초성) */
static readonly CHOSEONG: string[];
/** 2. Medial vowels (중성) */
static readonly JUNGSEONG: string[];
/** 3. Final consonants (종성) */
static readonly JONGSEONG: string[];
/** Hangul Composite Jamo(겹자모) -> Hangul Basic Jamo(기본 자모) */
protected static readonly JamoDecomposeMap: Map<string, string>;
/** Hangul Jamo -> Alphabet (in QWERTY 2벌식) */
protected static readonly QwertyMap: Map<string, string>;
/**
* say hello
*/
hello: () => string;
/**
* Identify whether given text is Hangul or not
*
* @param text input text
* @param partial (optional) if set true, result is true if there is at least one Korean letter in the text (default: false)
*/
isHangul(text: string, partial?: boolean): boolean;
/**
* Decompose text into Hangul (Compatibility) Jamo sequence
* - 초성, 중성, 종성으로 분해
* e.g. '한글' -> 'ㅎㅏㄴㄱㅡㄹ', '맴찟' -> 'ㅁㅐㅁㅉㅣㅅ'
*
* [Note]
* 유니코드 한글 자모는 초/중/종성에 서로 다른 코드 영역이 할당되어 있다.
* 따라서 동일한 자모라도 초성에 위치할 때와 종성에 위치할 때 코드값이 다르다.
* (예. 초성 'ㄱ': U+1100, 종성 'ㄱ': U+11A8)
* 이를 Compatibility Jamo로서 같은 코드값을 사용하도록 변형한다.
* [Reference]
* - https://en.wikipedia.org/wiki/Hangul_Jamo_(Unicode_block)
* - https://en.wikipedia.org/wiki/Hangul_Compatibility_Jamo
*
* @param text input text
*/
asJamoSequence(text: string): string;
/**
* Decompose the text to Hangul Basic Jamo sequence (for Search-As-You-Type)
* - 다양한 종류의 입력 방식(e.g. 세벌식) 지원을 위해 최소 단위인 기본 자모(24자)로 분해함
* e.g. '한글' -> 'ㅎㅏㄴㄱㅡㄹ', '맴찟' -> 'ㅁㅏㅣㅁㅈㅈㅣㅅ'
*
* @param text input text
*/
asBasicJamoSequence(text: string): string;
/**
* Transform to Alphabet key stroke sequence (for QWERTY/Korean 2-bul)
* e.g. '한글' -> 'gksrmf'
*
* @param text input text
*/
asAlphabetKeyStokes(text: string): string;
/**
* 초성만을 추출 (Korean only)
* e.g. 한글 -> ㅎㄱ
*
* @param text input text
*/
asChoseongSequence(text: string): string;
/**
* Check the code is Hangul Unicode character
*
* @param code character code
*/
static isHangulChar(code: number): boolean;
/**
* Check the code is Hangul syllable
*
* @param code character code
*/
static isHangulSyllable(code: number): boolean;
/**
* Check the code is Hangul Jamo
*
* @param code character code
*/
static isHangulJamo(code: number): boolean;
/**
* Check the code is Hangul Compatibility Jamo
*
* @param code character code
*/
static isHangulCompatibilityJamo(code: number): boolean;
}
declare const _default: HangulService;
export default _default;