Deterministic, semantic-safe Persian text preprocessing for AI, NLP, and search pipelines.
Project description
farsflow
farsflow is a lightweight Persian text preprocessing library focused on deterministic, semantic-safe normalization for modern AI and search pipelines.
❓ WHY farsflow??
Persian text often contains inconsistent spacing, Arabic/Persian character variants, invisible Unicode formatting characters, Arabic diacritics, and broken ZWNJ usage that negatively affect search, embeddings, NLP pipelines, and LLM applications.
farsflow provides a minimal and deterministic preprocessing layer designed to clean text without aggressive or semantic-destructive transformations.
🚀 Features
- Deterministic and semantic-safe normalization
- Safe ZWNJ (Joiner) correction
- Whitespace and punctuation cleanup
- Unicode cleanup (Arabic/Persian variants, Bidi controls, invisible formatting characters)
- Configurable normalization options (digit normalization & diacritics removal)
- Modular processors
- Zero dependencies
📦 Installation
pip install farsflow
✨ Quick Start
import farsflow as ff
text = "سلام دنیا! این یك تست است که می نویسم ۴۵۶"
cleaned = ff.clean(text)
print(cleaned)
Expected output:
سلام دنیا! این یک تست است که مینویسم 456
🧩 Pipeline Components
farsflow ships with a set of modular, composable components:
- Normalizer — character normalization, Unicode cleanup, and optional diacritics removal
- JoinerFixer — fixes ZWNJ usage without over-correction
- SpaceCleaner — trims redundant whitespace and punctuation spacing
- Pipeline — orchestrates components in a deterministic order
You can customize the pipeline:
from farsflow import (
Pipeline,
Normalizer,
SpaceCleaner,
)
pipeline = Pipeline([
Normalizer(),
SpaceCleaner(),
# JoinerFixer skipped to demonstrate modular behavior
])
text = "می نويسم که این يك متن تستي است"
cleaned = pipeline(text)
print(cleaned)
Expected output:
می نویسم که این یک متن تستی است
Design Principles
farsflow follows a few core principles:
- deterministic output
- semantic-safe transformations
- opt-in for potentially lossy operations
- zero dependencies
- modular architecture
🧪 Testing
pytest
# or:
pytest path/to/test_file.py
🗺 Roadmap (v0.2.0)
- configurable preprocessing profiles for different use cases
- optional emoji and URL cleanup processors
- compound word normalization (opt-in)
- additional normalization rules based on real-world corpora
- performance benchmarking and optimization
📄 License
MIT License — see LICENSE.
🤝 Contributing
Contributions are welcome.
Please open an issue or submit a pull request on GitHub.
📝 Changelog
See CHANGELOG for version history.
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 farsflow-0.1.1.tar.gz.
File metadata
- Download URL: farsflow-0.1.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b77d0f8a55d59877dfe29a474b1f08906efe9af5de7a98fb19e501719539d22
|
|
| MD5 |
5c8f73db1343c71bbf2700dc3b42057a
|
|
| BLAKE2b-256 |
242a5452006e8e5310ba335deceec847f832b23c1b7290a272d70b5023621968
|
File details
Details for the file farsflow-0.1.1-py3-none-any.whl.
File metadata
- Download URL: farsflow-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a9418c7a222a3442cd0bf52d5af3d976068b603ddb3a00b38ae0223235e5ec
|
|
| MD5 |
d67dee3d1e77778ebe622d49c9c60513
|
|
| BLAKE2b-256 |
393912b532e24d1b3d069eaa69f561c43773a45ef1b6534ca5b58f7c8d1ec0c5
|