# AraNorm

> Production-grade, dependency-free Arabic text normalization for Python: orthographic unification, dialect handling, Arabizi conversion, stop words, 45+ analyzers, CLI, and an optional HTTP server — one import, `process()`, done.

AraNorm (`pip install aranorm`, `import aranorm`) replaces the usual pile of incompatible Arabic tools with a single typed, tested library. It normalizes MSA and dialectal Arabic, converts Arabizi (Franco-Arabic) to Arabic script, identifies dialects (EGY/GLF/LEV/IRQ/NOR/TUN/YEM/MSA), converts them to CODA or MSA, removes or extracts stop words with per-dialect attribution, and ships 45+ linguistic analyzers (sentiment, readability, quality, keywords, similarity, corpus profiling) plus 44 CLI subcommands and a streaming/checkpointed batch engine. Zero required dependencies (Python >= 3.9), MIT license, deterministic output, 2300+ tests.

Quick start (verified):

```python
# pip install aranorm
import aranorm

pipeline = aranorm.ArabicNormalizationPipeline.from_preset("standard")
result = pipeline.process("الســـلامُ عليكم كيف حالكم اليوم؟")
result.normalized_text   # 'السلام عليكم كيف حالكم اليوم?'

# Dialect → MSA rewrite
cfg = aranorm.PipelineConfig.from_preset("standard", dialect_target="msa")
r = aranorm.ArabicNormalizationPipeline(cfg).process("شلونك اليوم؟ وين رايح")
r.dialect        # 'GLF'
r.msa_text      # 'كيف حالك اليوم? أين ذاهب'
```

Presets: `light` (minimal touch), `standard` (default), `deep` (search indexing), `social_media` (URLs/mentions/emojis/repetition). CLI: `aranorm normalize|stopwords|analyze|dialect|batch|serve|...` (44 subcommands; `aranorm version` is a subcommand). Server: `aranorm serve` then `POST /v1/normalize`.

Docs are bilingual: English in `docs/`, full Arabic mirror in `docs/ar/`. A flattened single-file version of this documentation is at [llms-full.txt](llms-full.txt).

## Getting started

- [Quick start](docs/getting-started.md): install, first pipeline, presets, result fields, batch basics
- [Configuration](docs/configuration.md): every `PipelineConfig` field, preset tables, validation, serialization
- [Examples](docs/examples.md): 20 runnable examples in `examples/`
- [Cookbook](docs/cookbook.md): 101 verified recipes for real-world scenarios
- [FAQ](docs/faq.md): common questions, both languages

## Core references

- [API reference](docs/api.md): all 67 public exports, verified signatures and outputs
- [Processors reference](docs/processors-reference.md): every processor class — options, verified examples, edge cases, ordering rules
- [Processors & presets](docs/processors.md): the processor catalogue grouped by stage
- [Analysis toolkit](docs/analysis.md): 45+ analyzers — sentiment, quality, readability, keywords, comparison, corpus
- [Utilities toolbox](docs/utils.md): `aranorm.utils` — tokenization, stemming/roots, language detection, quick helpers, stats, chunking for LLM/RAG, n-grams, fuzzy matching, keyboard-layout repair, cache, exporters, progress, validation
- [Error handling](docs/error-handling.md): every exception in the hierarchy with its real message, the three batch policies (default fail_fast), recovery patterns, CLI exit codes, HTTP error envelopes, anti-patterns — all execution-verified
- [CLI reference](docs/cli.md): all 44 subcommands, options, JSON output, error messages
- [Architecture](docs/architecture.md): stages, contracts, exception hierarchy

## Scenario guides

- [Dialects & codafication](docs/dialects.md): identification, EGY/GLF/LEV/.../MSA, CODA and MSA conversion
- [Arabizi](docs/arabizi.md): Franco-Arabic detection and conversion, full mapping tables
- [Stop words](docs/stopwords.md): 4 modes × 4 scopes, per-dialect and per-category lists, customization
- [Streaming](docs/streaming.md): resumable file-to-file sessions, checkpoints, locking, fingerprinting
- [Server](docs/server.md): HTTP API, batching, auth, hardening, deployment
- [Models (optional ML)](docs/models.md): HuggingFace backends for CODA/MSA/dialect-ID
- [For AI assistants & agents](docs/ai-assistants.md): normalization as an agent tool, sidecar service, RAG/fine-tuning presets, anti-patterns

## Operations

- [Performance](docs/performance.md): throughput numbers, caching, workers
- [Deployment](docs/deployment.md): containers, configs, rollout
- [Integrations](docs/integrations.md): pandas, scikit-learn, spaCy, NLTK, HF
- [Security & hardening](docs/security.md): input limits, PII, supply chain
- [Data files](docs/data-files.md): bundled lists and their formats
- [Testing](docs/testing.md): test philosophy, running, extending

## For developers

- [Developer guide](docs/development.md): repo layout, custom processors, plugin entry points
- [Style guide](docs/style-guide.md), [Migration](docs/migration.md), [Troubleshooting](docs/troubleshooting.md), [Glossary](docs/glossary.md) (159 terms, bilingual)

## Arabic documentation

- [الفهرس العربي](docs/ar/index.md): الدليل الكامل بالعربية — 30 ملفاً يطابق الإنجليزية بنيةً وأمثلة
