Skip to main content

Joint Khmer Part-of-Speech Tagger and Word Segmenter

Project description

Joint Khmer Part-of-Speech Tagger and Word Segmenter

An open-source part of speech tagger for Khmer language using BiLSTM.

The model weights can be downloaded in the release page.

Once downloaded, place the model weight at ckpt/best.pt

pip install -r requirements.txt

python infer.py

# Result => [
#   ("ខ្ញុំ", "PRO"),
#   ("ឈ្មោះ", "NN"),
#   ("ថូយ", "PN"),
#   ("ប៊ុន", "PN"),
#   ("ឡូ", "PN"),
#   ("ឆ្នាំ", "NN"),
#   ("នេះ", "DT"),
#   ("វា", "PRO"),
#   ("ត្រូវបាន", "VB"),
#   ("រាយការណ៍", "VB"),
#   ("ថា", "IN"),
#   ("បាន", "AUX"),
#   ("ធ្លាក់", "VB"),
#   ("ចុះ", "RB"),
#   ("មក", "IN"),
#   ("ត្រឹម", "IN"),
#   ("២,២", "CD"),
#   ("ភាគរយ", "NN"),
#   ("។", "KAN"),
#   ("លោក", "PRO"),
#   ("យ៉ាត់", "PN"),
#   ("សៀង", "PN"),
#   ("ហៃ", "PN"),
#   ("ជា", "IN"),
#   ("អ្នកធ្វើ", "NN"),
#   ("វា", "PRO"),
#   ("មែន", "RB"),
#   ("ទេ", "PA"),
#   ("?", "SYM"),
# ]

Library

To make thing easier to access, we made publish a simple library called khmertagger which can be installed with

pip install khmertagger
from khmertagger import tagger

output = tagger("ខ្ញុំឈ្មោះថូយប៊ុនឡូឆ្នាំនេះវាត្រូវបានរាយការណ៍ថាបានធ្លាក់ចុះមកត្រឹម២,២ភាគរយ។លោកយ៉ាត់សៀងហៃជាអ្នកធ្វើវាមែនទេ?")

print(output)
# Result => [
#   ("ខ្ញុំ", "PRO"),
#   ("ឈ្មោះ", "NN"),
#   ("ថូយ", "PN"),
#   ("ប៊ុន", "PN"),
#   ("ឡូ", "PN"),
#   ("ឆ្នាំ", "NN"),
#   ("នេះ", "DT"),
#   ("វា", "PRO"),
#   ("ត្រូវបាន", "VB"),
#   ("រាយការណ៍", "VB"),
#   ("ថា", "IN"),
#   ("បាន", "AUX"),
#   ("ធ្លាក់", "VB"),
#   ("ចុះ", "RB"),
#   ("មក", "IN"),
#   ("ត្រឹម", "IN"),
#   ("២,២", "CD"),
#   ("ភាគរយ", "NN"),
#   ("។", "KAN"),
#   ("លោក", "PRO"),
#   ("យ៉ាត់", "PN"),
#   ("សៀង", "PN"),
#   ("ហៃ", "PN"),
#   ("ជា", "IN"),
#   ("អ្នកធ្វើ", "NN"),
#   ("វា", "PRO"),
#   ("មែន", "RB"),
#   ("ទេ", "PA"),
#   ("?", "SYM"),
# ]

Dataset

The model is trained on ye-kyaw-thu/khPOS/ dataset. See ./data directory.

Train

python train.py

Evaluate

python evalulate.py

Metrics

Accuracy: 0.9409951303801445

License

MIT License

Copyright (c) 2025 Seanghay Yath

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

khmertagger-0.1.0.tar.gz (21.1 MB view details)

Uploaded Source

File details

Details for the file khmertagger-0.1.0.tar.gz.

File metadata

  • Download URL: khmertagger-0.1.0.tar.gz
  • Upload date:
  • Size: 21.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.19

File hashes

Hashes for khmertagger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 228d4f18acbc92f3686b0196a29c19e4b6ce2421aa169a7925cf318853393f44
MD5 9fba7fe99cf1aa95d5cbf2e6d9d280df
BLAKE2b-256 f3d5b0e051efd6870db23fab0547dce25143fc3ac2b5bab096a6904340182e87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page