A modern Python toolkit for Arabic Natural Language Processing (NLP).
Project description
Arabic NLP Toolkit
A lightweight, modular, and easy-to-use Python library for Arabic Natural Language Processing (NLP).
The toolkit provides common Arabic text preprocessing utilities including cleaning, normalization, tokenization, stopword removal, sentence segmentation, keyword extraction, similarity measurement, and more.
Features
Text Cleaning
- Remove URLs
- Remove Mentions (@username)
- Remove Hashtags (#hashtag)
- Remove Emojis
- Remove Arabic Diacritics (Tashkeel)
- Remove Tatweel (ـ)
- Remove Extra Spaces
Arabic NLP
- Arabic Text Normalization
- Arabic Tokenization
- Arabic Stopword Removal
- Sentence Splitting
- Word Frequency Analysis
- Word N-Grams
- Character N-Grams
- Keyword Extraction
- Language Detection
- Text Statistics
- Jaccard Text Similarity
Installation
pip install arabic-nlp-toolkit
Note
The package is currently under active development.
Quick Start
from arabinlp import preprocess
text = """
السَّلَامُ عَلَيْكُمْ 😊
زوروا موقعنا:
https://example.com
#الذكاء_الاصطناعي
"""
print(preprocess(text))
Output
السلام عليكم زوروا موقعنا: الذكاء_الاصطناعي
API Overview
from arabinlp import (
preprocess,
normalize_arabic,
tokenize,
remove_stopwords,
split_sentences,
word_frequency,
ngrams,
character_ngrams,
detect_language,
text_statistics,
extract_keywords,
jaccard_similarity,
)
Examples
Tokenization
from arabinlp import tokenize
tokenize("السلام عليكم ورحمة الله")
Output
['السلام', 'عليكم', 'ورحمة', 'الله']
Stopword Removal
from arabinlp import remove_stopwords
remove_stopwords("أنا أحب تعلم الذكاء الاصطناعي")
Output
['أحب', 'تعلم', 'الذكاء', 'الاصطناعي']
Sentence Splitting
from arabinlp import split_sentences
split_sentences(
"السلام عليكم. كيف حالك؟ أنا بخير!"
)
Output
[
'السلام عليكم.',
'كيف حالك؟',
'أنا بخير!'
]
Word Frequency
from arabinlp import word_frequency
word_frequency(
"الذكاء الذكاء الاصطناعي رائع"
)
Output
{
'الذكاء': 2,
'الاصطناعي': 1,
'رائع': 1
}
Word N-Grams
from arabinlp import ngrams
ngrams(
"السلام عليكم ورحمة الله",
n=2
)
Output
[
('السلام', 'عليكم'),
('عليكم', 'ورحمة'),
('ورحمة', 'الله')
]
Character N-Grams
from arabinlp import character_ngrams
character_ngrams(
"السلام",
n=3
)
Output
[
'الس',
'لسل',
'سلا',
'لام'
]
Language Detection
from arabinlp import detect_language
detect_language("Hello مرحبا")
Output
mixed
Text Statistics
from arabinlp import text_statistics
text_statistics(
"السلام عليكم. كيف حالك؟"
)
Output
{
'characters': 24,
'characters_without_spaces': 20,
'words': 4,
'unique_words': 4,
'sentences': 2
}
Keyword Extraction
from arabinlp import extract_keywords
extract_keywords(
"الذكاء الاصطناعي رائع. الذكاء يتطور بسرعة."
)
Output
[
'الذكاء',
'الاصطناعي',
'رائع'
]
Text Similarity
from arabinlp import jaccard_similarity
score = jaccard_similarity(
"أنا أحب الذكاء الاصطناعي",
"الذكاء الاصطناعي رائع"
)
print(score)
Output
0.4
Project Structure
arabic-nlp-toolkit/
├── arabinlp/
├── tests/
├── .github/
├── README.md
├── LICENSE
├── pyproject.toml
└── requirements.txt
Running Tests
python -m pytest
Current Status
40 tests passed
Roadmap
Version 1.1
- Arabic Light Stemmer
- Root Extraction
- TF-IDF
- BM25 Ranking
- Arabic Spell Checker
- Named Entity Recognition (NER)
- AraBERT Integration
Contributing
Contributions, bug reports, feature requests, and pull requests are always welcome.
If you have ideas for improving Arabic NLP support, feel free to open an Issue.
License
This project is licensed under the MIT License.
Author
Ibtihal Makki
AI Engineer • NLP Researcher • Generative AI
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 arabinlp-2.0.0.tar.gz.
File metadata
- Download URL: arabinlp-2.0.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
340cdfe8ebe7c57321d80b882578981c3d980d7a5f20ee2f31a5f357f9afbab9
|
|
| MD5 |
98ce62ccb3dba1a51fd9a2b5d0353ee5
|
|
| BLAKE2b-256 |
02eb3c4450706b8725d1b845ed90bde975baff9951a4971a3b0afa09f80f421e
|
Provenance
The following attestation bundles were made for arabinlp-2.0.0.tar.gz:
Publisher:
tests.yml on IbtihalMakki/arabic-nlp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arabinlp-2.0.0.tar.gz -
Subject digest:
340cdfe8ebe7c57321d80b882578981c3d980d7a5f20ee2f31a5f357f9afbab9 - Sigstore transparency entry: 2228870010
- Sigstore integration time:
-
Permalink:
IbtihalMakki/arabic-nlp-toolkit@4453f45ac5abbd4ceb7de1d128c0b12d5d38b020 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/IbtihalMakki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tests.yml@4453f45ac5abbd4ceb7de1d128c0b12d5d38b020 -
Trigger Event:
push
-
Statement type:
File details
Details for the file arabinlp-2.0.0-py3-none-any.whl.
File metadata
- Download URL: arabinlp-2.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df83c31ad778988d5f1ed5e406cd03689158952a88dacb4c9d1cae4bbbf38209
|
|
| MD5 |
bca9fff38fb8fe8e46a2a1323a383117
|
|
| BLAKE2b-256 |
a843771ee91e4275f79e432f50ad1f9ce865286b13b0a9eb572de9d778307bdc
|
Provenance
The following attestation bundles were made for arabinlp-2.0.0-py3-none-any.whl:
Publisher:
tests.yml on IbtihalMakki/arabic-nlp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arabinlp-2.0.0-py3-none-any.whl -
Subject digest:
df83c31ad778988d5f1ed5e406cd03689158952a88dacb4c9d1cae4bbbf38209 - Sigstore transparency entry: 2228870736
- Sigstore integration time:
-
Permalink:
IbtihalMakki/arabic-nlp-toolkit@4453f45ac5abbd4ceb7de1d128c0b12d5d38b020 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/IbtihalMakki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tests.yml@4453f45ac5abbd4ceb7de1d128c0b12d5d38b020 -
Trigger Event:
push
-
Statement type: