Skip to main content

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


Download files

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

Source Distribution

mlseg-0.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlseg-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

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

Hashes for mlseg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e13abbfbab23787a7bbe5c905b201ecb801a02103f444fa6ba940ebc34f747d0
MD5 6fc5f2c011c072d54e1986259eca88ec
BLAKE2b-256 b93d6653d1d57fff310e0265307be77787834b65995d81eed64158bae6470fd9

See more details on using hashes here.

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

Hashes for mlseg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3859777f664d63268aaad3deb702f1d11c7117141740fc95520ea79d4e678f04
MD5 85a26142eb006a6230942297b1c6f4a0
BLAKE2b-256 4f74e44fca5abf0759fab0f434d49ceae9cbca6b41d8a4e3e56e411d3b73472a

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