urdu-nlp-tools
Practical Python utilities for Urdu and Roman Urdu NLP: normalization, preprocessing, transliteration, lightweight augmentation, classification metrics, and sentiment analysis.
The default sentiment analyzer is dependency-free and works immediately with a small Urdu/Roman Urdu lexicon. For real research or production work, train it on your own labeled dataset with the optional scikit-learn extra.
Install
pip install urdu-nlp-tools
For TF-IDF + LinearSVC training:
pip install "urdu-nlp-tools[train]"
Quick Start
from urdu_nlp import SentimentAnalyzer
model = SentimentAnalyzer()
print(model.predict("یہ فلم بہت اچھی تھی"))
# positive
Batch prediction:
from urdu_nlp import SentimentAnalyzer
model = SentimentAnalyzer()
labels = model.predict([
"یہ فلم بہت اچھی تھی",
"movie bohat kharab thi",
])
print(labels)
Train Your Own Sentiment Model
CSV files should include a text column and a label column. By default, the helpers expect review and sentiment.
from urdu_nlp import SentimentAnalyzer, load_labeled_csv
records = load_labeled_csv("urdu_reviews.csv")
texts = [record.text for record in records]
labels = [record.label for record in records]
model = SentimentAnalyzer().fit(texts, labels)
model.save("urdu_sentiment.pkl")
loaded = SentimentAnalyzer.from_file("urdu_sentiment.pkl")
print(loaded.predict("یہ فلم بہت اچھی تھی"))
Text Utilities
from urdu_nlp import clean_text, normalize_urdu, roman_to_urdu, tokenize_words
print(normalize_urdu("كيا يہ ۱۲۳ ہے؟"))
print(clean_text("@user movie bohat achi thi!!!"))
print(tokenize_words("یہ فلم بہت اچھی تھی"))
print(roman_to_urdu("bohat achi film"))
Metrics
from urdu_nlp import accuracy_score, classification_report
y_true = ["positive", "negative", "neutral"]
y_pred = ["positive", "negative", "positive"]
print(accuracy_score(y_true, y_pred))
print(classification_report(y_true, y_pred))
CLI
urdu-nlp-sentiment "یہ فلم بہت اچھی تھی"
urdu-nlp-sentiment --model urdu_sentiment.pkl "movie bohat kharab thi"
Package Layout
urdu_nlp/
├── normalize.py
├── sentiment.py
├── transliteration.py
├── augmentation.py
├── preprocessing.py
└── metrics.py
Metadata
Release files for urdu-nlp-tools 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| urdu_nlp_tools-0.1.2.tar.gz | 14.1 kB | Without provenance | Details for urdu_nlp_tools-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| urdu_nlp_tools-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for urdu_nlp_tools-0.1.2-py3-none-any.whl |
Total release size: 28.3 kB
Release files / urdu_nlp_tools-0.1.2.tar.gz
| Download URL | urdu_nlp_tools-0.1.2.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a8e1aa2a49558f36438a32693b096b90e216964daa8d2e5e851fa792eb3f230
|
|
BLAKE2b-256 checksum How to use checksums |
eb2b69b9854aa3cd61815bac1b9bd293494a9156459aa01885b4482226b9cb93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / urdu_nlp_tools-0.1.2-py3-none-any.whl
| Download URL | urdu_nlp_tools-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a5399a58e5630b7e2a2b7a992c67622b12d196aa82fbd8a393986683c2c7cb8
|
|
BLAKE2b-256 checksum How to use checksums |
a2bb0f068d8d4dfc27317b318b8f18e24a8a3b8f29c5d2e62d66f7352d8e542c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for urdu-nlp-tools 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.