Skip to main content

Tiny Tamil text utilities: normalize, tokenize, stopwords, graphemes, n-grams, syllables, Tamil collation; dataset preprocessor; optional spaCy tokenizer hook.

Project description

tamil-utils

Tiny Tamil-first text utilities that make Unicode correctness & tokenization boringly reliable.

PyPI CI


Features

  • Core: normalize, tokens, remove_stopwords, graphemes, sents, Tamil⇄ASCII numerals, syllables (approx), Tamil collation (ISO-15919 key)

  • Counts: ngrams, word_counts (uni/bi/tri-grams, optional stopwords)

  • Pipelines: JSONL preprocessor (CLI + Python) for RAG/ML corpora

  • Integrations (optional):

    • spaCy tokenizer hook to mirror tamil_utils.tokens
    • Hugging Face Datasets export helper

Docs: https://arulnidhii.github.io/tamil-utils/


Install

pip install tamil-utils

# optional extras
pip install "tamil-utils[spacy]"   # spaCy hook
pip install datasets               # HF datasets helper

Quick start

from tamil_utils import (
    normalize, tokens, remove_stopwords, graphemes, sents,
    to_arabic_numerals, syllables, sort_tamil, word_counts
)

s = "இது ஒரு சோதனை 👩🏽‍💻 ௨௦௨௫"

print(tokens(s))                                # ['இது','ஒரு','சோதனை','👩🏽‍💻','௨௦௨௫']
print(remove_stopwords(tokens(s), preset="ta")) # ['சோதனை','👩🏽‍💻','௨௦௨௫']
print(graphemes("👩🏽‍💻"))                       # ['👩🏽‍💻']
print(sents("இது ஒன்று. இது இரண்டு? சரி!"))      # ['இது ஒன்று.', 'இது இரண்டு?', 'சரி!']
print(to_arabic_numerals("௨௦௨௫"))                 # "2025"
print(syllables("தமிழ்"))                         # approx syllable-ish groups
print(sort_tamil(["இலங்கை","ஆதி","அடி"]))         # ['அடி','ஆதி','இலங்கை']
print(word_counts("தமிழ் NLP தமிழ் NLP", n=2, top=3))

CLI

# JSONL preprocessor (one record per line)
python -m tamil_utils.cli preprocess --numerals ar --rmstop < input.txt > out.jsonl

# Word/n-gram counts
python -m tamil_utils.cli freq -n 2 --top 5 "தமிழ் NLP தமிழ் NLP"

# Tamil collation sort (ISO-15919 key)
python -m tamil_utils.cli sort "இலங்கை" "ஆதி" "அடி"

Windows PowerShell

When piping Tamil text, prefer UTF-8 files or run with python -X utf8.


spaCy tokenizer (optional)

import spacy
from tamil_utils.spacy_hook import install_tamil_tokenizer

nlp = spacy.blank("xx")
install_tamil_tokenizer(nlp)
[t.text for t in nlp("இது ஒரு சோதனை 2025")]
# ['இது','ஒரு','சோதனை','2025']

Hugging Face Datasets (optional)

from tamil_utils.hf_export import to_hf_dataset  # requires: pip install datasets

records = [{"text": "இது ஒரு சோதனை 2025",
            "tokens": ["இது","ஒரு","சோதனை","2025"]}]
ds = to_hf_dataset(records)
print(ds)

License

MIT © Arulnidhi Karunanidhi

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

tamil_utils-0.4.0a1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

tamil_utils-0.4.0a1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file tamil_utils-0.4.0a1.tar.gz.

File metadata

  • Download URL: tamil_utils-0.4.0a1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for tamil_utils-0.4.0a1.tar.gz
Algorithm Hash digest
SHA256 ba67a87b8227a5ca047e5425f23a81659a999ddb9169ac640ab661595cad7cc1
MD5 a2664dd4fed8e6f87bae9ed7a6511293
BLAKE2b-256 95fce7f49bfad7923dd19b705c25f6d2aeb6cc430f95010af1fb0d8617240867

See more details on using hashes here.

File details

Details for the file tamil_utils-0.4.0a1-py3-none-any.whl.

File metadata

  • Download URL: tamil_utils-0.4.0a1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for tamil_utils-0.4.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe8ef56128e0f600d7dfb69b4b7899a65b2712bcc27e82e60186966ee603bf34
MD5 70f813c4b9b1fa217d593b0845d4dfc8
BLAKE2b-256 06aa46817a47d6bbced3689d8383bafbba08a5c929526e8a2f648de15794a2ed

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