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)

What’s new in v0.4” bullet:

Corpus utilities: normalize_punct, dedup_lines, filter_by_length, window_sents

New CLI: corpus-dedup, corpus-filter, corpus-windows

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tamil_utils-0.4.0.tar.gz
  • Upload date:
  • Size: 19.8 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.0.tar.gz
Algorithm Hash digest
SHA256 870ef74bdde86b8dd28db36c0efb9f241b9635a1e0ce170cb8bc8aea1a2f0804
MD5 b93de327bf8b286b5c7b642f0b2db28f
BLAKE2b-256 c7287a87fe56a628d1e9077294d1d10a8a2e9d802acc89c1bbf806a8c3ac2dae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tamil_utils-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be63955f9cda539c5e735243ccf9c547a9afa0fff74713de2dfdb60e4c03bcf1
MD5 ccfd88ff9cac47ee8d2d7c457aa9a4c6
BLAKE2b-256 ae7f4bc051d1a9ef5a76068f9a4d36b99135b35d28122da9702bca8d49fb72fd

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