Skip to main content

Canonicalization and Darija Representation - Bidirectional transliteration for Darija

Project description

CaDaR: Canonicalization and Darija Representation

High-performance bidirectional transliteration for Darija (Moroccan Arabic)

License: Apache-2.0 Python 3.8+ Rust

Overview

CaDaR is a robust, FST-style (Finite State Transducer) transliteration library designed specifically for Darija (Moroccan Arabic). It provides bidirectional conversion between Arabic script and Latin (Romanized/Bizi) script, along with standardization capabilities for both scripts.

Key Features

  • Bidirectional Transliteration: Convert seamlessly between Arabic and Latin scripts
  • Intelligent Normalization: Handles noise, diacritics, and common variations
  • Darija-Aware Processing: Respects Darija-specific linguistic patterns
  • Intermediate Canonical Representation (ICR): Unified internal representation for accurate conversion
  • High Performance: Written in Rust with Python bindings for optimal speed
  • Extensible: Designed to support multiple Darija dialects (currently Moroccan)

Architecture

CaDaR uses a 6-stage pipeline with an Intermediate Canonical Representation (ICR):

Raw Input
   ↓
Stage 1: Script Detection
   ↓
Stage 2: Noise Cleaning & Normalization
   ↓
Stage 3: Tokenization (Darija-aware)
   ↓
Stage 4: Canonical Darija Representation (ICR)
   ↓
Stage 5: Target Script Generation
   ↓
Stage 6: Post-validation & Fixes
   ↓
Clean Standard Output

What is ICR?

The Intermediate Canonical Representation (ICR) is the core innovation of CaDaR. It's a script-independent, phonologically-grounded representation that:

  • Abstracts away script-specific quirks
  • Preserves Darija phonological distinctions
  • Enables lossless round-trip conversions
  • Allows for consistent normalization across scripts

Installation

From PyPI

pip install cadar

From Source

Prerequisites

  • Python 3.8 or higher
  • Rust toolchain (for building from source)
  • Maturin (for Python packaging)

Build and Install

# Clone repository
git clone https://github.com/Oit-Technologies/CaDaR.git
cd CaDaR

# Install Maturin
pip install maturin

# Build and install in development mode
maturin develop

# Or build a wheel for distribution
maturin build --release

Usage

Python API

CaDaR provides four main functions that match the requested API:

1. ara2bizi() - Arabic to Latin/Bizi

import cadar

result = cadar.ara2bizi("سلام", darija="Ma")
print(result)
# Output: "slam"

2. bizi2ara() - Latin/Bizi to Arabic

import cadar

result = cadar.bizi2ara("salam", darija="Ma")
print(result)
# Output: "سلام"

3. ara2ara() - Arabic Standardization

import cadar

result = cadar.ara2ara("أنَا", darija="Ma")
print(result)
# Output: "انا"

4. bizi2bizi() - Latin/Bizi Standardization

import cadar

result = cadar.bizi2bizi("salaaaam", darija="Ma")
print(result)
# Output: "salam"

Convenience Functions

CaDaR also provides convenience functions with auto-detection:

import cadar

# Auto-detect and transliterate
text = "سلام"  # Arabic
result = cadar.transliterate(text, target="latin", darija="Ma")
print(result)  # "slam"

# Auto-detect and standardize
text = "salaaaam"
result = cadar.standardize(text, script="auto", darija="Ma")
print(result)  # "salam"

CaDaR Class

For multiple operations, use the CaDaR class:

import cadar

# Create processor
processor = cadar.CaDaR(darija="Ma")

# Use for multiple operations
texts = ["سلام", "كيفاش", "بزاف"]
for text in texts:
    result = processor.ara2bizi(text)
    print(f"{text}{result}")

Version History

See CHANGELOG.md for details.

License

CaDaR is licensed under the Apache License 2.0.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Links

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

cadar-0.1.13.dev0.tar.gz (457.0 kB view details)

Uploaded Source

Built Distributions

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

cadar-0.1.13.dev0-cp312-cp312-win_amd64.whl (851.2 kB view details)

Uploaded CPython 3.12Windows x86-64

cadar-0.1.13.dev0-cp312-cp312-manylinux_2_34_x86_64.whl (961.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

cadar-0.1.13.dev0-cp312-cp312-macosx_11_0_arm64.whl (844.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cadar-0.1.13.dev0-cp311-cp311-win_amd64.whl (850.8 kB view details)

Uploaded CPython 3.11Windows x86-64

cadar-0.1.13.dev0-cp311-cp311-manylinux_2_34_x86_64.whl (960.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

cadar-0.1.13.dev0-cp311-cp311-macosx_11_0_arm64.whl (846.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cadar-0.1.13.dev0-cp310-cp310-win_amd64.whl (851.0 kB view details)

Uploaded CPython 3.10Windows x86-64

cadar-0.1.13.dev0-cp310-cp310-manylinux_2_34_x86_64.whl (960.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

cadar-0.1.13.dev0-cp310-cp310-macosx_11_0_arm64.whl (846.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

cadar-0.1.13.dev0-cp39-cp39-manylinux_2_34_x86_64.whl (961.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

cadar-0.1.13.dev0-cp38-cp38-manylinux_2_34_x86_64.whl (961.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file cadar-0.1.13.dev0.tar.gz.

File metadata

  • Download URL: cadar-0.1.13.dev0.tar.gz
  • Upload date:
  • Size: 457.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cadar-0.1.13.dev0.tar.gz
Algorithm Hash digest
SHA256 f6814ec5b11e3c841a42a9cd5d5ceb54220ff2e19ca74b508ff73086869e2ebb
MD5 3705bd9d2e607db8e515c4020957e3d4
BLAKE2b-256 9ab8315d05c77b5580dd7bea5c318a192d68d3a878b6c07d26e99c8c247bf9fd

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6de89095e7ba6c79af725565d1cc3fbbd1fea925f744166d1e3a9cbcbed15aae
MD5 804efd973345b380b581ee4231874bc8
BLAKE2b-256 4b4885aba914daf3012cca3c722e992d2a22345b4ec543caabf7972f04667fc6

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d1fccd7d1fc24f276023c30db7e4aa3002f881c0a11e773cd60fad3d652f97e3
MD5 be80e89eb0056cf6108f9fbd33d87262
BLAKE2b-256 3f43f19a0a0c8bc029fb8dd3f3015c4d28bc71e333cd4c52307fb40223cc8a96

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f22d949c4612df7cf3319ae6e496c74cc640d1746502f9fa22a1b152e7e3a345
MD5 34f65122623aaad6b85355077a7fcabf
BLAKE2b-256 5c34756403178529f57b2163eaec1ae58bd43bdedbbd6dc35b02edd4429b4089

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6d890317dd3d263c547b441325b3b8f707d6c7405d9b173eadc9524481f89824
MD5 082cd41bb6747b0e98767932b20d0d06
BLAKE2b-256 3e171e1e4f7c6df8390f3a5e8b8c43fd9116f78be6230a54498ebb77b3ac86fb

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b6d7719319846ca80b03883e4468e8a325d362d07f2a1664f3cde491fee3a61a
MD5 0a02048f40dab6b0a72072326d5afe69
BLAKE2b-256 45275fbceed41c5148b5f1d3f2e25289b072a728bc774f2f19438a85db330f62

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 679c5a35dbb3c5752c217effc491b10f4cdf5bb4225092d5925b3064a0811a28
MD5 e8d5a4519ad405b01dc6499fedc0a76f
BLAKE2b-256 4a327b18414cde8fa1ed989264d6ccd44f81585aa4ad8079028212424634b599

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1c0e9e9e8381048e9fc5557d853587dbf517034baf67b35ceff6caf7aa2df475
MD5 bdb25e14d6a6e6923da3876eded66c37
BLAKE2b-256 dc561b14c2cf00de40df78f1ad5a0fd4ab9b55ad79df147df5f016a18158b3a3

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b64f3c7ae1cbdc6d05ece4c03d15d97c7edfd99d8c320dde6ea3cfd375392586
MD5 eb9646f90edcbce9c39b599ca0a857b6
BLAKE2b-256 ea4726684939b2ea52a50895a14266f196ab497bcb219fa3492a6e5443f73cd2

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b64e342ef0354091ae2e90bfd8fa52693bd433def9d4f1456090145a7c505b96
MD5 355c84612f5c5c03e3efd17fadacf38a
BLAKE2b-256 e361fba1867353ef30e3e61ce3002be47792a636bc791810dfe0cc35ee4ad46e

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c786feb00d7f3357f8661529b7423444b71b66a7d9fe367b9d13c26505f4156e
MD5 ac78d7cc03ecdc3698badc7119bdf12d
BLAKE2b-256 f51face926a580d65c26f5884f4964a648b9bde92c8ad60669005405b3ee4f0a

See more details on using hashes here.

File details

Details for the file cadar-0.1.13.dev0-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cadar-0.1.13.dev0-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 832e0d869bb2ba4d9e1abc1c3bab8fc34208831d0245681f9949d0443121a77f
MD5 147328b9ee03027b08bed3970634a42b
BLAKE2b-256 ea58a94dc82667fc006302e803581c03a8ba37db89bdf8dab3adacee30576805

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