Skip to main content

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 .txt file 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:

  1. Fork the repo
  2. Create a new branch
  3. Commit your changes
  4. Submit a Pull Request

Made with ❤️ in Pakistan 🇵🇰 for the Roman Urdu NLP community.

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

romanrekhta-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

romanrekhta-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for romanrekhta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f243b033bea40c21605b3247e8b3bd6a92deba97a1b33998bd5b40921d895d52
MD5 8b46cc37b533e240ebfa68799ab7ea78
BLAKE2b-256 3aac5a68e7aa0ccb715b2c41f3909db5c8106a12f53f5719ba8a273af6d801f4

See more details on using hashes here.

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

Hashes for romanrekhta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51cf7880155d83f8330b7cc6743d0f5e050a7b0b511c3b9097b7514c1c1402be
MD5 87b1e61e85c634cf90175281860c8bf5
BLAKE2b-256 2f29418828a771d0f793bd261e79e380f621e87c7ec013980e467015de1f4af1

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