An NLP library for Roman Urdu text preprocessing, tokenization, and stopword handling.
Project description
🇵🇰 romanRekhta
romanRekhta is a lightweight, flexible, and extensible Python library for Roman Urdu Natural Language Processing (NLP). It provides essential tools for text preprocessing, tokenization, and stopword removal tailored to Roman Urdu, a widely used informal script across Pakistan and South Asia.
Features
- Modular preprocessing (lowercasing, punctuation removal, emoji handling)
- Flexible stopword filtering (from
.txtfile or custom list) - Tokenization (word and sentence level)
- Easily extendable and community-contributable
Installation
pip install -e .
# When published
pip install romanRekhta
Quick Start
from romanRekhta.preprocessing import Preprocessor
text = "Apka service boht achi hai! 😍🔥"
# Remove emojis and punctuation
pre = Preprocessor(lowercase=True, emoji_handling="remove")
cleaned = pre.process(text)
print(cleaned) # Output: apka service boht achi hai
Emoji Options:
"remove"→ Deletes emojis"replace"→ Converts 😊 → smiling_face"ignore"→ Leaves emojis untouched
Stopword Removal
from romanRekhta.stopwords import StopwordHandler
# Load from file and extend with custom stopwords
stop_handler = StopwordHandler(
filepath="stopwords.txt",
custom_stopwords={"mera", "nahi"}
)
tokens = ["ye", "mera", "kaam", "nahi", "acha", "hai"]
filtered = stop_handler.remove_stopwords(tokens)
print(filtered) # Output: ['ye', 'kaam', 'acha']
# Load only from file
stop_handler = StopwordHandler(filepath="stopwords.txt")
tokens = ["ye", "bohat", "acha", "kaam", "hai"]
filtered = stop_handler.remove_stopwords(tokens)
print(filtered) # Output: ['ye', 'bohat', 'acha', 'kaam']
# Custom stopword list only
custom_words = {"mera", "tumhara"}
stop_handler = StopwordHandler(custom_stopwords=custom_words)
tokens = ["ye", "mera", "bohat", "acha", "kaam", "nahi"]
filtered = stop_handler.remove_stopwords(tokens)
print(filtered) # Output: ['ye', 'bohat', 'acha', 'kaam']
# Combine file + custom stopwords
stop_handler = StopwordHandler(
filepath="stopwords.txt",
custom_stopwords={"nahi", "kya"}
)
tokens = ["ye", "nahi", "kya", "acha", "kaam"]
filtered = stop_handler.remove_stopwords(tokens)
print(filtered) # Output: ['ye', 'acha', 'kaam']
Tokenization
from romanRekhta.tokenizer import word_tokenize, sentence_tokenize
text = "Yeh idea bohat acha hai. Shukriya!"
# Word tokenization
tokens = word_tokenize(text)
print(tokens) # ['Yeh', 'idea', 'bohat', 'acha', 'hai', 'Shukriya']
# Sentence tokenization
sentences = sentence_tokenize(text)
print(sentences) # ['Yeh idea bohat acha hai', ' Shukriya']
# Advanced tokenization method
tokens = word_tokenize(text, method="regex")
Configurable Preprocessor Options
| Option | Type | Default | Description |
|---|---|---|---|
lowercase |
bool | True | Convert to lowercase |
punctuation |
bool | True | Remove punctuation |
emoji_handling |
str | remove | Options: 'remove', 'replace', 'ignore' |
normalize_space |
bool | True | Remove extra whitespaces |
remove_non_ascii_chars |
bool | False | Remove emojis and symbols |
File-Based Stopwords
Place a stopwords.txt file in your project or repository.
Each line should contain one Roman Urdu stopword.
Contributing
We welcome contributors to improve this library! Here’s how you can help:
- Add more Roman Urdu stopwords to
stopwords.txt - Suggest or implement new features (normalization, spell checker, sentiment analysis)
- Report bugs or edge cases
To contribute:
- Fork the repo
- Create a new branch
- Commit your changes
- Submit a Pull Request
Made with ❤️ in Pakistan 🇵🇰 for the Roman Urdu NLP community.
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 romanrekhta-0.1.0.tar.gz.
File metadata
- Download URL: romanrekhta-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f243b033bea40c21605b3247e8b3bd6a92deba97a1b33998bd5b40921d895d52
|
|
| MD5 |
8b46cc37b533e240ebfa68799ab7ea78
|
|
| BLAKE2b-256 |
3aac5a68e7aa0ccb715b2c41f3909db5c8106a12f53f5719ba8a273af6d801f4
|
File details
Details for the file romanrekhta-0.1.0-py3-none-any.whl.
File metadata
- Download URL: romanrekhta-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51cf7880155d83f8330b7cc6743d0f5e050a7b0b511c3b9097b7514c1c1402be
|
|
| MD5 |
87b1e61e85c634cf90175281860c8bf5
|
|
| BLAKE2b-256 |
2f29418828a771d0f793bd261e79e380f621e87c7ec013980e467015de1f4af1
|