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.3.0.tar.gz (17.1 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.3.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file tamil_utils-0.3.0.tar.gz.

File metadata

  • Download URL: tamil_utils-0.3.0.tar.gz
  • Upload date:
  • Size: 17.1 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.3.0.tar.gz
Algorithm Hash digest
SHA256 a7359113939cc003f6242dd6fcc3c824e172c0b6a02d48e51a26610c48da9667
MD5 0a22f6e45a2515101ddd8d95b39798ae
BLAKE2b-256 13b2d1653f67fec98e80ad84adfb2ce00430e23d9b4a4219be4c65ceb72a547d

See more details on using hashes here.

File details

Details for the file tamil_utils-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tamil_utils-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b2628a61365a5921d6aaeb0cfff15a8e80fa5e2c0d0102e8940e8ab64420185
MD5 e18e01f2644aac71739ba79a43701ba7
BLAKE2b-256 148629980bf04bad20dfdbd9f0ccf28ca25a4ccf1ed7682ebe91c9f542ca0cc1

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