Skip to main content

ตัดคำภาษาไทยความเร็วสูงด้วย Rust

kham เป็นไลบรารีสำหรับ NLP ภาษาไทยพร้อมใช้งาน ไม่มี dependency ภายนอก มี core แบบ no_std รองรับ Rust, WebAssembly, Python, C, PostgreSQL และ SQLite no_std

# Cargo.toml kham-core = "0.5"
$ pip install kham
$ npm install kham-wasm

ครอบคลุมทุกความต้องการของ Thai NLP

ไลบรารีเดียวสำหรับ pipeline ทั้งหมด ตั้งแต่ข้อความดิบจนถึง token พร้อม metadata

รวดเร็ว

Maximal Matching บน DAWG dictionary ที่บีบอัดแล้ว ทำงานได้ 42–47 MiB/s บน Apple M-series โดยมีความแม่นยำ F1 0.975

📦

รองรับหลายแพลตฟอร์ม

หนึ่ง core หลายเป้าหมาย: Rust crate, WebAssembly, Python (PyO3), C FFI, CLI, PostgreSQL FTS parser และ SQLite FTS5 tokenizer

🔒

no_std core

kham-core เป็น pure Rust แบบ no_std + alloc ทำงานได้ใน embedded, WASM และทุกสภาพแวดล้อมที่ไม่มี standard library

🌐

pipeline NLP ครบชุด

ตัดคำ, POS tagging, Named Entity Recognition, romanization (RTGS), phonetic codes (lk82/udom83/MetaSound) และ normalize ตัวเลข

API ที่เรียบง่าย ไม่คัดลอกข้อมูล

ตัดคำภาษาไทยพร้อม byte span และ char span สำหรับ search indexing, NLP pipeline และการเชื่อมต่อกับทุกภาษา

คู่มือเริ่มต้นใช้งาน →
main.rs
use kham_core::Tokenizer;

let tok = Tokenizer::new();
let tokens = tok.segment("กินข้าวกับปลา");
// ["กิน", "ข้าว", "กับ", "ปลา"]

ทดลองใช้งานเดี๋ยวนี้

ขับเคลื่อนด้วย WebAssembly — ทำงานในเบราว์เซอร์ทั้งหมด ไม่ต้องใช้เซิร์ฟเวอร์

Samples:

พร้อมนำไปใช้งานแล้วหรือยัง?

เพิ่ม kham ใน Rust, Python หรือ Node.js ของคุณได้ภายในไม่กี่นาที