# madi (마디)
순수 Rust 한국어 형태소 분석기 **madi** 의 라이브러리 진입점. 세종 품사 태그(NNG, VV, EF …)로 형태소를 나누고, 형태소 분석을 이용한 문장 분리도 합니다. Python 패키지는 `pip install madipy`(import `madi`).
A Korean morphological analyzer written in pure Rust (Sejong tag set, morpheme-aware sentence splitting). This crate is the library entry point (`Engine`); the command-line tool is `madi-cli`, the Python package is `madipy`.
## 사용 / Usage
```toml
[dependencies]
madi = "0.1" # 신경망 LM 포함 (feature nlm)
# madi = { version = "0.1", default-features = false } # KnLM 만
```
```rust
let cfg = madi::EngineConfig {
knlm: Some("knlm.bin".into()),
nlm: Some("model.nlm".into()),
lm_weight: 0.7,
nlm_weight: 0.3,
..madi::EngineConfig::new("madi.dict")
};
let engine = madi::Engine::load(&cfg)?; // Send + Sync — 스레드마다 worker() 하나
println!("{}", engine.version()); // 0.1.1+decdb.r3p.f11.k838c.n15e6.s0968 (모델·설정 확인용)
let mut w = engine.worker();
for s in w.analyze_doc("아버지가 방에 들어가신다. 감기는 무서운 병이다.") {
for t in &s.tokens {
print!("{}/{} ", t.form, t.tag.code());
}
println!();
}
```
모델 파일(`madi.dict`·`knlm.bin`·`model.nlm`·`precise.tlm`)은 크레이트에 들어 있지 않습니다. GitHub Release 에서 받습니다:
https://github.com/p14jeffwest/madi-release/releases (Python 패키지는 처음 쓸 때 자동으로 받습니다.)
Model files are not in the crate; download them from the release repository above.
## 이용 조건 / License
코드는 MIT 또는 Apache-2.0 중 택일입니다(저장소의 `LICENSE-MIT`·`LICENSE-APACHE`). 모델·사전 파일은 따로 배포하며 CC BY-SA 2.0 KR 입니다 — https://github.com/p14jeffwest/madi-release
Code: MIT OR Apache-2.0. Model files are distributed separately (CC BY-SA 2.0 KR), see the release repository above.