Khmer word segmentation, POS tagging, NER, and more — powered by a custom Khmer language model
Project description
khmer-nlp-kcc
Khmer NLP toolkit — word segmentation, POS tagging, and sentiment polarity.
Powered by a custom Khmer language model. The checkpoint is downloaded automatically from HuggingFace Hub on first use.
Installation
pip install khmer-nlp-kcc
Quick start
from khmer_nlp import KhmerNLP
nlp = KhmerNLP() # checkpoint downloads on first call
# Word segmentation
nlp.segment("គាត់ចូលចិត្តអានសៀវភៅ")
# → ["គាត់", "ចូលចិត្ត", "អាន", "សៀវភៅ"]
# POS tagging
nlp.pos("គាត់ចូលចិត្តអានសៀវភៅ")
# → [{"word": "គាត់", "label": "PRO"}, {"word": "ចូលចិត្ត", "label": "VB"}, {"word": "អាន", "label": "VB"}, {"word": "សៀវភៅ", "label": "NN"}]
# Sentiment polarity
nlp.polarity("ខ្ញុំចូលចិត្តប្រទេសខ្មែរណាស់")
# → {"label": "positive", "confidence": 0.9944, "scores": {"negative": 0.0023, "neutral": 0.0032, "positive": 0.9944}}
# All tasks at once
nlp.analyze("គាត់ចូលចិត្តអានសៀវភៅ")
Custom checkpoint
nlp = KhmerNLP(checkpoint_path="/path/to/your/model.pt")
Device selection
import torch
nlp = KhmerNLP(device=torch.device("cuda:0"))
Available methods
| Method | Returns | Description |
|---|---|---|
segment(text) |
list[str] |
Segmented word list |
pos(text) |
list[dict] |
Word + POS label |
polarity(text) |
dict |
Sentiment polarity |
analyze(text) |
dict |
All tasks combined |
Raw token-level outputs: seg_tokens(), pos_tokens().
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file khmer_nlp_kcc-0.2.3.tar.gz.
File metadata
- Download URL: khmer_nlp_kcc-0.2.3.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f48b3063fafe6eecb6caa70601de821f160c7fce93c910e9609a443a5901ad22
|
|
| MD5 |
dc7bbc5de61fc247b722df5cf1ab0405
|
|
| BLAKE2b-256 |
0c69993055280f3ff3be80a6aff88dd7cf1c89da117a38596937c49627bf3015
|
File details
Details for the file khmer_nlp_kcc-0.2.3-py3-none-any.whl.
File metadata
- Download URL: khmer_nlp_kcc-0.2.3-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
361caad4f8dae745f7fda0bd4fc6b08f67c6314ec39f09b8fe1b96926d6ee7ba
|
|
| MD5 |
7140a71689bb4a424e3e943520589029
|
|
| BLAKE2b-256 |
4d2f0e45088638f8cd7f7cf04fc29f6071c8a8b82297413083d120d7a081dc07
|