A robust text normalizer tool for Bangla language
Project description
Bangla Text Normalizer
A robust, dependency-free Python package for normalizing Bangla text. It converts numbers, dates, phone numbers, and more into their spoken Bangla textual representation.
Installation
pip install bangla-text-normalizer
Usage
from bangla_text_normalizer import BanglaTextNormalizer
normalizer = BanglaTextNormalizer()
# Example 1: Addresses and Numbers
text = "৫ম তলা, ৩/বি, গুলশান-২, ঢাকা ১২১২"
print(normalizer.normalize(text))
# Expected Output:
# পঞ্চম তলা, ৩/বি, গুলশান-২, ঢাকা এক দুই এক দুই
# Example 2: Dates (Smart Pronunciation)
print(normalizer.normalize("21/02/1952"))
# Output: একুশে ফেব্রুয়ারি ঊনিশশো বাহান্ন
# Example 3: Phone Numbers
print(normalizer.normalize("01711000000"))
# Output: শূন্য এক সাত এক এক শূন্য শূন্য শূন্য শূন্য শূন্য শূন্য
# Example 4: Decimals and Fractions
print(normalizer.normalize("3.5"))
# Output: তিন দশমিক পাঁচ
Features
- Number Conversion: Converts integers to text (Supports extremely large numbers like Lakhs/Crores).
- Date Normalization:
- Handles
DD/MM/YYYYformats. - Context-aware dates:
21->একুশে(Ekmshe),01->পহেলা(Pohela). - Smart Year handling:
1952->ঊনিশশো বাহান্ন(Nineteen Hundred Fifty-Two),2024->দুই হাজার চব্বিশ.
- Handles
- Phone Numbers:
- Normalizes BD phone numbers (e.g.,
017...,+88017...) into individual digits. - Robust handling of spaces and hyphens (e.g.,
017 11000000).
- Normalizes BD phone numbers (e.g.,
- Ordinals:
- Supports numeric ordinals:
1st,2nd,10th. - Supports Bangla short-forms:
১ম,২য়,১০ম. - Auto-generates ordinals for large numbers:
1023rd->এক হাজার তেইশতম.
- Supports numeric ordinals:
- Decimals & Fractions: Handles floating point numbers (
3.1416) and simple fractions (1/2). - Zero Dependency: Pure Python implementation with no external requirements.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bangla_text_normalizer-0.1.0.tar.gz.
File metadata
- Download URL: bangla_text_normalizer-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c0e55cc30685153d5ab3102998a3ad99c567e69f79f19a5c769bb5ad1a4588
|
|
| MD5 |
a2b0ba1b76486255c8b577528cd3bafe
|
|
| BLAKE2b-256 |
c4b862ed4972799f2c54d73246647caae2afc1f19e06bd611bfc647d794ffd52
|
File details
Details for the file bangla_text_normalizer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bangla_text_normalizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
759ba3f038fec3d70e2d30b3c3e7706ba580862afa89c329bc9de7863cb0bafb
|
|
| MD5 |
0737f93daba2981d2d85fb43a585ef19
|
|
| BLAKE2b-256 |
9781e125d05ac6ea7243cf99287850461678f350c84f4a635e3b17274f52fedc
|