Kannada tokenizer with sandhi splitting for Information Retrieval.
Project description
kannada-tokenizer
Tokenize Kannada text with sandhi splitting for Information Retrieval.
pip install kannada-tokenizer
Quick start
from kannada_tokenizer import tokenize
tokenize("ಬೆಂಗಳೂರು ಭಾರತದ ಸಿಲಿಕಾನ್ ಕಣಿವೆ")
# ['ಬೆಂಗಳೂರು', 'ಭಾರತದ', 'ಸಿಲಿಕಾನ್', 'ಕಣಿವೆ']
tokenize("ವಿದ್ಯಾಲಯದಲ್ಲಿ ಮಕ್ಕಳು ಕಲಿಯುತ್ತಾರೆ")
# ['ವಿದ್ಯಾಲಯದಲ್ಲಿ', 'ಮಕ್ಕಳು', 'ಕಲಿಯುತ್ತಾರೆ']
tokenize("ದೇವಾಲಯದ ಮಹೋತ್ಸವ")
# ['ದೇವಾಲಯದ', 'ಮಹೋತ್ಸವ']
tokenize() accepts both Kannada script and ISO 15919 romanized input. Splits on whitespace and punctuation, applies reverse sandhi rules, and outputs Kannada script.
Sandhi splitting
from kannada_tokenizer.sandhi import split_sandhi
split_sandhi("ರಾಮಾಯಣ") # savarṇa-dīrgha: a + ā → ā
# ['ರಾಮ', 'ಆಯಣ']
split_sandhi("ದೇವಾಲಯ") # lōpa: a + ā → ā
# ['ದೇವ', 'ಆಲಯ']
split_sandhi("ವಿದ್ಯಾಲಯ") # lōpa: a + ā → ā
# ['ವಿದ್ಯ', 'ಆಲಯ']
split_sandhi("ಸರ್ವಜ್ಞ") # lōpa: a + a → a
# ['ಸರ್ವ', 'ಅಜ್ಞ']
split_sandhi("ಕನ್ನಡ") # no junction found
# ['ಕನ್ನಡ']
Accepts Kannada script or ISO 15919 — output script matches input. Rule-based engine covering lōpa sandhi (vowel elision), āgama sandhi (y/v insertion), ādeśa sandhi (guṇa-like substitution), and consonant sandhi (voicing, gemination, nasals).
Transliteration
from kannada_tokenizer.transliterate import (
kannada_to_iso15919,
iso15919_to_kannada,
is_kannada,
)
kannada_to_iso15919("ಶ್ರೀರಂಗಪಟ್ಟಣ")
# 'śrīraṃgapaṭṭaṇa'
kannada_to_iso15919("ಜ್ಞಾನಪೀಠ")
# 'jñānapīṭha'
iso15919_to_kannada("mahārāṣṭra")
# 'ಮಹಾರಾಷ್ಟ್ರ'
kannada_to_iso15919("ಬೆಂಗಳೂರು")
# 'beṃgaḻūru'
is_kannada("ಕುವೆಂಪು")
# True
Handles Kannada's short/long e/o distinction (ಎ→e vs ಏ→ē), the retroflex lateral ಳ→ḻ, conjunct consonants (ಕ್ಷ, ಜ್ಞ, ಶ್ರೀ), and perfect round-trip fidelity.
Word-level tokenization
from kannada_tokenizer.tokenizer import tokenize_words
tokenize_words("ಮಹಾತ್ಮ ಗಾಂಧಿ ರಾಷ್ಟ್ರಪಿತ")
# ['ಮಹಾತ್ಮ', 'ಗಾಂಧಿ', 'ರಾಷ್ಟ್ರಪಿತ']
tokenize_words() splits on whitespace and punctuation only — no sandhi splitting.
CLI
kannada-tokenize "ಕನ್ನಡ ನಾಡಿನ ಭಾಷೆ"
# ಕನ್ನಡ
# ನಾಡಿನ
# ಭಾಷೆ
echo "ವಿದ್ಯಾಲಯದಲ್ಲಿ ಮಕ್ಕಳು ಕಲಿಯುತ್ತಾರೆ" | kannada-tokenize
# ವಿದ್ಯಾಲಯದಲ್ಲಿ
# ಮಕ್ಕಳು
# ಕಲಿಯುತ್ತಾರೆ
kannada-tokenize -s " " "ಬೆಂಗಳೂರು ಮಹಾನಗರ"
# ಬೆಂಗಳೂರು ಮಹಾನಗರ
--no-sandhi— word-level only, skip sandhi splitting--separator SEP— output separator (default: newline)
License
MIT © Hemanth.HM
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
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 kannada_tokenizer-0.1.3.tar.gz.
File metadata
- Download URL: kannada_tokenizer-0.1.3.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3550cbbcd786b5d98ad2fcef6f66b8b3409a9566f2243e83f7c2ea26f0fe09a
|
|
| MD5 |
2c5dbbc7cd2373ee038babaf91a40e31
|
|
| BLAKE2b-256 |
9d4f60cef9ac91e6a895fa6de36966fcaedd36892a467eea8c8d043add0bf951
|
File details
Details for the file kannada_tokenizer-0.1.3-py3-none-any.whl.
File metadata
- Download URL: kannada_tokenizer-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd6f0035630faa2b95954733b6ee85de8690786d83c4650ba6667836ef7b8f27
|
|
| MD5 |
962c4430b3d84c6f3b7062592f7fbb96
|
|
| BLAKE2b-256 |
b87a827d39766c78e6f183fb930ec07fc9f1b9bfcb6099eef9a8b788ffce6cf4
|