Rule-based Malayalam surface segmenter (conservative morphological fallback).
Project description
mlseg
A rule-based Malayalam surface segmenter. Given an inflected word, it splits it
into a stem plus its case / number suffixes. It is the rough inverse companion to
mlinflect (which generates inflected
forms): mlseg takes one apart.
from mlseg import segment
segment("കുട്ടികൾ") # ['കുട്ടി', 'കൾ']
segment("വീട്ടിൽ") # ['വീട്', 'ഇൽ']
segment("പുസ്തകങ്ങളിൽ") # ['പുസ്തകം', 'ങ്ങൾ', 'ഇൽ']
segment("മരം") # ['മരം'] (no recognised suffix, returned whole)
What it does
segment(word) applies a small set of native-ratified surface rules: it strips
a recognised case suffix (locative, sociative, directive, genitive) and a plural
(കൾ / ങ്ങൾ), reverting the well-known geminate (…ട്ടി -> …ട്) and
restoring chillu and anusvaram lemmas where the alternation is sound and
reversible. Suffixes come back in their lemma spelling, in surface order (stem
first, outermost suffix last).
Conservative by construction
This is a best-effort fallback for words a full morphological analyser cannot
handle, not an analyser itself. It splits only on a rule whose surface-to-lemma
realisation has been ratified by a native reviewer. If no rule matches, it
returns the word whole ([word]); it never invents a split and never fabricates
Malayalam (no guessed viramas, no fabricated stems). A minimum-stem floor blocks
over-stripping of real words whose tail merely looks like a suffix (മകൾ
"daughter", കോട്ട് "coat"). segment is idempotent on bare stems.
Limitations
There is no lexicon, so a proper name whose tail happens to match a suffix
surface and clears the 2-akshara floor can be false-split, e.g. the name അനിൽ
(Anil) becomes ['അൻ', 'ഇൽ']. Distinguishing such a name from a true locative
needs a lexicon or NER. Callers that need certainty should prefer a full
analyser; this fills the gap when one is unavailable.
Install
pip install mlseg
# from source:
pip install -e ".[dev]"
mlseg depends on mlnormalize for input normalisation, so geminate and chillu
comparisons are byte-stable. It is on PyPI, so pip install mlseg pulls it in
automatically.
License
Apache-2.0. See LICENSE and NOTICE. Contributions are accepted under Apache-2.0
section 5 (inbound = outbound); no separate CLA is required.
Linguistic sources are credited in REFERENCES.md.
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 mlseg-0.1.0.tar.gz.
File metadata
- Download URL: mlseg-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e13abbfbab23787a7bbe5c905b201ecb801a02103f444fa6ba940ebc34f747d0
|
|
| MD5 |
6fc5f2c011c072d54e1986259eca88ec
|
|
| BLAKE2b-256 |
b93d6653d1d57fff310e0265307be77787834b65995d81eed64158bae6470fd9
|
File details
Details for the file mlseg-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlseg-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3859777f664d63268aaad3deb702f1d11c7117141740fc95520ea79d4e678f04
|
|
| MD5 |
85a26142eb006a6230942297b1c6f4a0
|
|
| BLAKE2b-256 |
4f74e44fca5abf0759fab0f434d49ceae9cbca6b41d8a4e3e56e411d3b73472a
|