Skip to content

fix: Kiwi v0.23.0 지원 및 Functional Options 패턴 적용 (Resolves #41)#42

Open
kkweon wants to merge 5 commits into
mainfrom
fix/update-to-kiwi-0.23.0
Open

fix: Kiwi v0.23.0 지원 및 Functional Options 패턴 적용 (Resolves #41)#42
kkweon wants to merge 5 commits into
mainfrom
fix/update-to-kiwi-0.23.0

Conversation

@kkweon
Copy link
Copy Markdown
Member

@kkweon kkweon commented May 18, 2026

개요 (Overview)

이 PR은 #41 이슈를 해결하기 위해 작성되었습니다.
Kiwi C 라이브러리가 v0.23.0으로 업데이트되면서 발생한 API 호환성 문제(함수 시그니처 불일치)를 수정하고, Go 라이브러리의 사용성을 개선하기 위해 코드를 리팩토링했습니다.

변경 사유 및 상세 내용 (Why & What)

  1. Kiwi v0.23.0 C API 호환성 대응

    • kiwi_initkiwi_builder_init 함수에 enabled_dialects 매개변수가 추가됨에 따라, C 호출 시 해당 인자를 전달하도록 수정했습니다.
    • kiwi_analyze 함수가 단순 int 형태의 옵션 대신 kiwi_analyze_option_t 구조체를 받도록 변경되었습니다. 이에 맞춰 내부적으로 C 구조체를 생성하여 전달하도록 수정했습니다.
  2. Functional Options 패턴 도입

    • Kiwi v0.23.0부터 방언(Dialect), 오타 교정 임계값(Typo threshold), 방언 페널티(Dialect cost) 등 세부적인 float 옵션들이 추가되었습니다.
    • 이를 기존처럼 함수의 고정 매개변수로 전부 노출하면 API가 매우 복잡해지고 매직 넘버(예: 1, 3.0, 2.5)를 호출부에서 강제하게 됩니다.
    • 따라서 Go에서 널리 쓰이는 Functional Options 패턴(opts ...Option)을 적용하여 기본 유스케이스는 최대한 단순하게 유지하면서, 고급 기능이 필요한 사용자는 WithTopN(), WithNumThread(), WithDialect() 등을 통해 유연하게 설정할 수 있도록 리팩토링했습니다.
  3. 테스트 및 Makefile 버그 수정

    • Kiwi v0.23.0 모델 압축 해제 시 models/cong/base/ 하위 경로로 풀리는 문제를 해결하여, make test 시 매번 모델을 다시 다운로드하지 않고 정상적으로 캐싱되도록 Makefile을 수정했습니다.
    • 새 C 라이브러리 버전에 맞춰 형태소 분석 확률 점수(Score) 가중치가 미세하게 변동된 부분을 테스트 코드에 반영했습니다.

관련 이슈

This commit addresses the API breaking changes introduced in Kiwi v0.23.0 where new parameters like `enabled_dialects` and structs like `kiwi_analyze_option_t` were introduced.

To resolve compilation failures and provide a clean idiomatic Go interface, the API was refactored to use the Functional Options pattern.

Changes include:
- Updated Makefile to download Kiwi v0.23.0
- Refactored `New` and `NewBuilder` to use `Option` callbacks.
- Refactored `Analyze` to use `AnalyzeOptionFunc` callbacks, defaulting TopN to 1.
- Updated all test cases to reflect the new API and new model scoring weights.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kiwigo: Kiwi C 라이브러리 v0.23.0과의 API 호환성 문제 - 함수 시그니처 불일치

2 participants