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.5.0a1.tar.gz (23.3 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.5.0a1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tamil_utils-0.5.0a1.tar.gz
  • Upload date:
  • Size: 23.3 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.5.0a1.tar.gz
Algorithm Hash digest
SHA256 fa14c432b886ab6ee159fa137625a4e034365f8819164ba41e95afc856533ade
MD5 14c37d7cc6715f1d6d6e145a7b120a5f
BLAKE2b-256 32edf615e8945599c9d71ad3e955fd52aa8dbf80f39aba08c25d792522b1b3f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tamil_utils-0.5.0a1-py3-none-any.whl
  • Upload date:
  • Size: 21.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.5.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a9aab832685eaa5c48eff3eb3b214cf94526c7eac41dc3d9e30cc4840d71e62
MD5 2be1202ee88bb2a0e468b5654ea01370
BLAKE2b-256 25ee86bec6d71a07797ce8fa4c701c565b8e1b11f3d91f078d9349691c68ef6a

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