Skip to main content

Persian-Ya

PyPI version Python Versions CI Status Coverage License

مستندات فارسی (Persian Documentation)

A lightweight, zero-dependency, production-ready Python package that correctly attaches adjectives, titles, and descriptions to Persian proper nouns (names) and phrases following Persian Ezafe (Kasre-ye Ezafe / Yaye Mianji) grammatical rules.


Features

  • Zero Dependencies: Pure standard Python 3.10+ with ultra-fast string parsing.
  • 100% Grammar Accuracy: Correctly handles Persian vowel endings (ا, و), silent He (ه, ة, ۀ), and all 32 consonants.
  • Customizable Silent He Style: Switch seamlessly between modern standard (\u200cی - ZWNJ + Ye) and formal Academy style (ٔ - Hamze).
  • Persian Normalizer: Cleans Arabic characters (ي $\rightarrow$ ی, ك $\rightarrow$ ک), stray ZWNJs, diacritics/harakat, and extra whitespace.
  • Compound Names & Titles Support: Properly formats multi-word names (e.g., "محمد رضا" $\rightarrow$ "محمد رضای عزیز").
  • Fully Typed: Includes PEP 561 py.typed marker and complete type hints.
  • 100% Test Coverage: Thoroughly tested across all linguistic edge cases.

Installation

Install via pip:

pip install persian-ya

Or using uv:

uv add persian-ya

Quick Start

Basic Usage

from persian_ya import attach_adjective

# 1. Names ending in "ا" (Alef) or "و" (Vav) -> Appends 'ی'
print(attach_adjective("رضا", "عزیز"))  # Output: 'رضای عزیز'
print(attach_adjective("مینو", "گرامی"))  # Output: 'مینوی گرامی'

# 2. Names ending in "ه" (Silent He) -> Default modern style (ZWNJ + 'ی')
print(attach_adjective("پروانه", "عزیز"))  # Output: 'پروانه‌ی عزیز'

# 3. Names ending in consonants or "ی" -> Standard space concatenation
print(attach_adjective("مریم", "عزیز"))  # Output: 'مریم عزیز'
print(attach_adjective("علی", "عزیز"))  # Output: 'علی عزیز'

Silent He Style Switch (ya vs hamze)

You can easily configure the orthography for words ending in silent He (ه / ة):

from persian_ya import HeStyle, attach_adjective

# Modern Standard (Default): ZWNJ + 'ی'
print(attach_adjective("پروانه", "عزیز"))
# Output: 'پروانه‌ی عزیز'

# Formal / Academy Style (Hamze / Small Ye):
print(attach_adjective("پروانه", "عزیز", he_style="hamze"))
# Output: 'پروانهٔ عزیز'

# Using the boolean convenience flag:
print(attach_adjective("پروانه", "عزیز", use_hamze=True))
# Output: 'پروانهٔ عزیز'

# Using the HeStyle Enum:
print(attach_adjective("پروانه", "عزیز", he_style=HeStyle.HAMZE))
# Output: 'پروانهٔ عزیز'

Compound Names & Multi-Word Titles

from persian_ya import attach_adjective

print(attach_adjective("محمد رضا", "عزیز"))  # 'محمد رضای عزیز'
print(attach_adjective("امیر علی", "گرامی"))  # 'امیر علی گرامی'
print(attach_adjective("سید محمد رضا", "محترم"))  # 'سید محمد رضای محترم'
print(attach_adjective("دکتر پروانه", "گرامی"))  # 'دکتر پروانه‌ی گرامی'

Extracting Suffixes Directly

from persian_ya import get_ezafe_suffix

print(get_ezafe_suffix("رضا"))  # 'ی'
print(get_ezafe_suffix("مینو"))  # 'ی'
print(get_ezafe_suffix("پروانه"))  # '\u200cی' (‌ی)
print(get_ezafe_suffix("پروانه", he_style="hamze"))  # 'ٔ' (\u0654)
print(get_ezafe_suffix("مریم"))  # ''
print(get_ezafe_suffix("علی"))  # ''

Text Normalization

from persian_ya import normalize_persian

raw_text = "  على   رضاى   عَزِيز  "
clean_text = normalize_persian(raw_text)
print(clean_text)  # 'علی رضای عزیز'

Persian Grammar Reference

Word Ending Ezafe Rule Example Output
Alef (ا) Append "ی" "رضا" + "عزیز" "رضای عزیز"
Vav (و) Append "ی" "مینو" + "گرامی" "مینوی گرامی"
Silent He (ه) ZWNJ + "ی" (Default) "پروانه" + "عزیز" "پروانه‌ی عزیز"
Silent He (ه) Hamze (ٔ) "پروانه" + "عزیز" (he_style="hamze") "پروانهٔ عزیز"
Consonants (32 letters) Space separation only "مریم" + "عزیز" "مریم عزیز"
Terminal Ye (ی) Space separation only "علی" + "عزیز" "علی عزیز"

Development & Testing

Clone & Install

git clone https://github.com/Mazafard/persian-ya.git
cd persian-ya
pip install -e ".[dev]"

Run Tests with Coverage

uv run pytest

Run Type Checking & Linting

uv run mypy src/
uv run ruff check .

License

This project is licensed under the MIT License.

Release files for persian-ya 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for persian-ya 0.1.0
File Size Uploaded
persian_ya-0.1.0.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for persian-ya 0.1.0
File Interpreter ABI Platform
persian_ya-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / persian_ya-0.1.0.tar.gz

Download URL persian_ya-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
690a913c588d41e59f9ca1fa27c2b08fd0345da9943a62e09ec75b48dffedf72
BLAKE2b-256 checksum
How to use checksums
a06cec7292b791f394ff0c994e90e9fb69508c38871470077429bd7c991c0b3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / persian_ya-0.1.0-py3-none-any.whl

Download URL persian_ya-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c641ff271e04b0314c3769c6f84e9a806cb2ed6f48c953d18d4c99267e5f492b
BLAKE2b-256 checksum
How to use checksums
9a1315f4479a9506da2ac8fac3285110e68eeab9413a983acbca69ea02382854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page