Package io.github.bangjunyoung
Class KoreanTextMatcher
Object
io.github.bangjunyoung.KoreanTextMatcher
한글 음절 근사 매칭 클래스.
이 클래스는 문자 수준에서의 음절 근사 매칭 API를 포함하고 있는
KoreanCharApproxMatcher의 상위 서비스로 문자열 수준에서의 음절 근사 매칭
API를 포함하고 있다.
한글 음절 근사 매칭은 두 개의 한글 음절을 비교할 때 음절을 이루는 자모의 일부만
일치해도 두 음절이 같은 것으로 간주하는 매칭 방법이다. 예를 들어 일반적인 문자
비교에서 '밝'은 'ㅂ', '바', '발'과 다른 문자로
간주되지만 음절 근사 매칭에서는 '밝'에 'ㅂ', '바',
'발'이 모두 부합하는 것으로 간주한다.
단, 여기서 주의할 점은 자모의 개수가 다른 두 음절간 비교시 교환성이 성립하지
않는다는 것이다. 예를 들어 '발'은 '밝'에 부합하지만
'밝'은 '발'에 부합하지 않는다. 즉, 자모의 개수가 더 많은 음절에
대해 자모의 개수가 더 적은 음절을 비교하는 쪽으로 매칭이 이루어져야 한다는 뜻이다.
매칭에 사용할 자모로 Unicode Hangul Jamo와 Hangul Compatibility Jamo를 모두 지원한다.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean주어진text내에 주어진pattern이 존재하는지 여부를 조사한다.static KoreanTextMatch주어진text내에서 주어진pattern의 첫번째 출현을 찾는다.static Iterable<KoreanTextMatch>주어진text내에서 주어진pattern의 모든 출현을 찾는다.
-
Constructor Details
-
KoreanTextMatcher
- Parameters:
pattern- 검색할 패턴- Throws:
IllegalArgumentException-pattern이null일 때.
-
-
Method Details
-
match
주어진text에 대해KoreanTextMatcher(String)에서 지정해 둔pattern의 첫번째 출현을 찾는다.text내 검색 시작 위치를 지정하려면match(String, int)를 사용한다.- Parameters:
text- 검색 대상 문자열- Returns:
- 검색 결과를 담은
KoreanTextMatch인스턴스.KoreanTextMatch.success()가true일 때만 유효하다. 검색이 실패하면KoreanTextMatch.EMPTY를 리턴한다. - Throws:
IllegalArgumentException-text가null일 때.
-
match
- Parameters:
text- 검색 대상 문자열startIndex- 검색을 시작할text내 위치- Returns:
- 검색 결과를 담은
KoreanTextMatch인스턴스.KoreanTextMatch.success()가true일 때만 유효하다. 검색이 실패하면KoreanTextMatch.EMPTY를 리턴한다. - Throws:
IllegalArgumentException-text가null일 때, 또는startIndex가0보다 작거나text.length()보다 클 때.
-
matches
주어진text에 대해KoreanTextMatcher(String)에서 지정해 둔pattern의 모든 출현을 찾는다.text내 검색 시작 위치를 지정하려면matches(String, int)를 사용한다.- Parameters:
text- 검색 대상 문자열- Returns:
- 검색 결과를 담은
Iterable<KoreanTextMatch>인스턴스. 찾은 것이 없으면 빈 리스트를 리턴한다. - Throws:
IllegalArgumentException-text가null일 때.
-
matches
- Parameters:
text- 검색 대상 문자열startIndex- 검색을 시작할text내 위치- Returns:
- 검색 결과를 담은
Iterable<KoreanTextMatch>인스턴스. - Throws:
IllegalArgumentException-text가null일 때, 또는startIndex가0보다 작거나text.length()보다 클 때.
-
isMatch
주어진text내에 주어진pattern이 존재하는지 여부를 조사한다. 정규식 앵커^와$를 사용하여pattern의 위치를 검색 대상 문자열의 시작과 끝으로 한정할 수 있다.- Parameters:
text- 검색 대상 문자열pattern- 검색할 패턴- Returns:
text내에pattern이 존재하면true, 그렇지 않으면false.- Throws:
IllegalArgumentException-text또는pattern이null일 때.
-
match
주어진text내에서 주어진pattern의 첫번째 출현을 찾는다. 모든 출현을 찾으려면matches(String, String)를 사용한다. 정규식 앵커^와$를 사용하여pattern의 위치를 검색 대상 문자열의 시작과 끝으로 한정할 수 있다.- Parameters:
text- 검색 대상 문자열pattern- 검색할 패턴- Returns:
- 검색 결과를 담은
KoreanTextMatch인스턴스.KoreanTextMatch.success()가true일 때만 유효하다. 검색이 실패하면KoreanTextMatch.EMPTY를 리턴한다. - Throws:
IllegalArgumentException-text또는pattern이null일 때.
-
matches
주어진text내에서 주어진pattern의 모든 출현을 찾는다. 첫번째 출현만 찾으려면match(String, String)를 사용한다. 정규식 앵커^와$를 사용하여pattern의 위치를 검색 대상 문자열의 시작과 끝으로 한정할 수 있다.- Parameters:
text- 검색 대상 문자열pattern- 검색할 패턴- Returns:
- 검색 결과를 담은
Iterable<KoreanTextMatch>인스턴스. - Throws:
IllegalArgumentException-text또는pattern이null일 때.
-