Skip to main content

Inverse Text Normalization (ITN) for Indic languages

Project description

indic-itn (v0.2.1)

Inverse Text Normalization (ITN) for Indic languages (Hindi, Telugu, Kannada, etc.).

indic-itn converts spoken-form ASR (Automatic Speech Recognition) transcriptions into normalized written representations across currency, date, decimal, number, OTP, percentage, phone, and time entities.


Installation

pip install indic-itn

Or install locally in editable mode for development:

pip install -e ".[dev]"

Usage

1. Hindi ITN

from indic_itn import HindiITN

itn = HindiITN()

# Numbers & Currency
print(itn.normalize("पाँच लाख साठ हजार रुपये"))
# Output: "₹560000"

# Time & Date
print(itn.normalize("पाँच बजकर तीस मिनट"))
# Output: "5:30"

2. Telugu ITN

from indic_itn import TeluguITN

itn = TeluguITN()

# Numbers & Currency
print(itn.normalize("రెండు వందల రూపాయలు"))
# Output: "₹200"

# Phone & OTP
print(itn.normalize("నా నంబర్ తొమ్మిది ఎనిమిది ఏడు ఆరు ఐదు నాలుగు మూడు రెండు ఒకటి సున్నా"))
# Output: "నా నంబర్ 9876543210"

3. Kannada ITN

from indic_itn import KannadaITN

itn = KannadaITN()

# Percentage & Decimal
print(itn.normalize("ಮೂರು ಬಿಂದು ಒಂದು ನಾಲ್ಕು"))
# Output: "3.14"

print(itn.normalize("ಇಪ್ಪತ್ತೈದು ಶೇಕಡಾ"))
# Output: "25%"

4. Generic Multi-Lingual Factory (IndicITN)

from indic_itn import IndicITN

# Dynamically instantiate ITN for any supported language code
hi_itn = IndicITN(lang="hi")
te_itn = IndicITN(lang="te")
kn_itn = IndicITN(lang="kn")
ta_itn = IndicITN(lang="ta")  # Tamil

5. Checking Supported Languages Programmatically

from indic_itn import IndicITN, get_supported_languages

# Call classmethod on IndicITN
print(IndicITN.get_supported_languages())
# Output: ['hi', 'kn', 'ta', 'te']

# Or call top-level utility function
print(get_supported_languages())
# Output: ['hi', 'kn', 'ta', 'te']

Supported Entity Types

Entity Type Example Spoken Input Normalized Output
Number "कक्षा दो" / "తరగతి రెండు" / "ತರಗತಿ ಎರಡು" "कक्षा 2" / "తరగతి 2" / "ತರಗತಿ 2"
Currency "दो सौ रुपये" / "రెండు వందల రూపాయలు" / "ಎರಡು ನೂರು ರೂಪಾಯಿ" "₹200"
Date "पच्चीस दिसंबर दो हजार पच्चीस" "25 दिसंबर 2025"
Time "पाँच बजकर तीस मिनट" / "ఐదు ಗంటల ముప్పై నిమిషాలు" "5:30"
Decimal "तौम्मिदि दशमलव पाँच" / "మూడు పాయింట్ ఒకటి నాలుగు" "9.5" / "3.14"
Percentage "इरवै आईदु प्रतिशत" / "ಇಪ್ಪತ್ತೈದು ಶೇಕಡಾ" "25%"
Phone "मेरा नंबर नौ आठ सात छह पाँच चार तीन दो एक शून्य" "मेरा नंबर 9876543210"
OTP "मेरा ओटीपी छह पाँच चार तीन दो एक" "मेरा ओटीपी 654321"

Development and Tooling

Running Tests and Coverage

pytest --cov=indic_itn --cov-report=term-missing

Code Formatting and Linting

ruff check .
ruff format --check .

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

indic_itn-0.2.1.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

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

indic_itn-0.2.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file indic_itn-0.2.1.tar.gz.

File metadata

  • Download URL: indic_itn-0.2.1.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for indic_itn-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c9fd8d306c0567ee443ffd7d28454e90e2f9c2c20db3ac655a735024406c0c27
MD5 f59f7c61e60245f62889090098cd73bc
BLAKE2b-256 444f4793b3174f4cfb70d31ca0c7b2bce1e57a857c36302e8e69231e4f9d26b1

See more details on using hashes here.

File details

Details for the file indic_itn-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: indic_itn-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for indic_itn-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af257506c1f744e76b90bc0bef348286dcdce5037cfa3139ac66a655cb54ecb3
MD5 74ed4aefacad522f10a4f5a4afab8e26
BLAKE2b-256 b4a1ffdc7aa3bed01c98ef702ce64851ccbd0cb274669ba622f51dd3097b7942

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