AraPrepLab
AraPrepLab is a desktop tool for Arabic text classification that answers one practical question: which cleaning steps actually improve results on my data?
Arabic text is written in many ways. The same word can appear with or without diacritics, with different alef or hamza forms, with stretched letters, or in a dialect spelling. Studies disagree on which of these to normalize, and whether to stem, because the answer changes from one dataset to another. AraPrepLab lets you load your own spreadsheet, test the cleaning choices on it, and see which ones make a real difference. You don't need to write any code, and nothing leaves your computer.
More screenshots: data and audit, cleaning preview, model check, BERT check, Auto analysis, experiment running, topics, prediction and export.
What it does
-
Data audit: class balance, the score you would get by always guessing the largest class, exact and near duplicates (with a box to drop repeated texts), duplicates with different labels, Arabizi rows, empty rows, and how many texts use common dialect words.
-
Cleaning steps you can switch on and off:
- 12 normalization steps, two of them dialect aware;
- an MSA stopword list;
- two stemmers (light10 and ISRI);
- negation marking, which tags the two words after ما، مش، لا، لم and similar words so that "مش طيب" is not read as "طيب".
Negation words are never removed or stemmed.
-
The experiment:
- trains a classifier on many cleaning combinations with the same repeated cross-validation folds;
- measures the effect of each step from pairs of setups that differ only in that step;
- tests each effect with the corrected resampled t-test (Nadeau and Bengio, 2003) and Holm's correction, so a lucky difference isn't reported as a real one;
- runs one planned test of "all steps vs raw text", and shows the best setup with a note that picking it from many setups makes its gap look larger than it is.
-
Models: linear SVM, logistic regression and complement naive Bayes, on word or character TF-IDF features. The vectorizer is fitted on the training folds only. You can register any scikit-learn classifier from Python.
-
Topics with NMF or LDA that leave out very common words and show stems as real words, a final model you can try on new sentences, and model save/load.
-
Model check: a confusion matrix and the list of texts the model gets wrong, each predicted by a model that never saw it.
-
BERT check (optional): compares your chosen TF-IDF setup (usually the best one from the experiment) with a pretrained Arabic BERT model (CAMeLBERT, AraBERT or MARBERT) on the same folds, with the same corrected t-test. The model is downloaded once and then runs offline.
-
Auto analysis: the whole workflow with one click, ending in a short plain-language summary that can be saved as text or as a full JSON report.
-
Help as you go: a bar at the bottom shows which steps are done and what to do next, every setting has a tooltip, and the results open with a short summary in plain words.
-
Reproducibility:
- one random seed for everything;
- saved sessions;
- a JSON report of every run;
- every action in the app (loading, cleaning, experiment, topics, training, predictions, exports) is logged, and the log can be saved as a Python script or a Jupyter notebook that repeats the whole session without the app;
- an environment capsule with package versions and
pip freeze.
Install
You need Python 3.10 or newer, on Windows or Linux.
pip install arapreplab
From a copy of this repository:
pip install -e ".[dev]"
With conda:
conda env create -f environment.yml
conda activate arapreplab
For the optional BERT check (adds torch and transformers, about 1 GB):
pip install "arapreplab[bert]"
Quick start
Start the app:
python -m arapreplab
- Data: click Open file… and pick a CSV or Excel file (or Load sample data). Check the text and label columns, then click Use columns & audit.
- Cleaning: tick steps and click Preview to see the text before and after.
- Experiment: click Run experiment. The window stays usable while it runs.
- Results: see which steps help, hurt or make no clear difference, then Use best configuration.
- Topics, Predict & Export and the optional BERT check do the rest. Save session keeps all your settings for next time.
Or load your file and press ⚡ Auto analysis (top bar). It does the work of tabs 1 to 6 in order, recommends a cleaning setup with a fixed rule (only steps that clearly help; raw text if nothing does), tests it on texts the model has not seen, trains the final model, finds topics, and explains the result in plain words. Every tab is filled in afterwards, so you can look closer.
The same analysis from Python, without the GUI:
from arapreplab.core import ExperimentSettings, run_experiment
from arapreplab.io import load_table
df = load_table("examples/data/oclar.csv")
result = run_experiment(df["review"], df["sentiment"], ExperimentSettings(n_splits=5, n_repeats=5, seed=42))
for e in result.effects:
print(e.factor, e.level, round(e.mean_diff, 4), round(e.p_holm, 3), e.verdict)
More examples are in examples/. To see the whole workflow with its tables and charts in one place, open
examples/walkthrough.ipynb (pip install -e ".[notebook]", then jupyter notebook).
Command line and automation
The whole analysis also runs without the app:
arapreplab auto my_data.csv # results go to a folder next to the file
arapreplab auto my_data.csv --preset quick --text review --label sentiment --dedup
It saves the summary, a full JSON report, the effects table and chart, and the trained model. arapreplab serve
starts a small web service on your computer so other programs can run the same analysis. examples/n8n uses it
for an n8n workflow: a web form where someone uploads a file, and the results arrive by email,
with every run logged to a spreadsheet. The data stays on your computer.
Methods and sources
docs/methods.md lists where every cleaning step and statistical method comes from (light10, ISRI, the
Nadeau and Bengio test, Holm's correction and others) and how each one was checked.
Data
examples/data/ holds three public datasets, already cleaned. SOURCES.md lists the exact changes made to each.
| File | Rows | Text | License | Source |
|---|---|---|---|---|
oclar.csv |
3,916 | Lebanese reviews of hotels, restaurants and shops | CC BY 4.0 | Omari et al. 2019, doi:10.24432/C5SP66 |
arabic_twitter.csv |
1,995 | Tweets in MSA and Jordanian Arabic | CC BY 4.0 | Abdulla 2013, doi:10.24432/C5F31B |
arsarcasm.csv |
10,547 | Tweets labelled for sentiment, sarcasm and dialect | MIT | Abu Farha and Magdy 2020 |
sample_reviews.csv is made-up data for demos and tests only.
Reproducing the paper
python examples/reproduce_paper.py
This runs every case study in the paper with the same seed and writes the results and a summary table to
results/. It takes about 30 to 60 minutes on a laptop. The numbers came out identical, to four decimals, on Windows 11
and Ubuntu Linux. To rebuild the data files from the original downloads, see examples/prepare_datasets.py.
To check the numbers independently, run:
python examples/check_results.py
It confirms the dataset counts against the published ones and recomputes the raw-text scores with plain scikit-learn. It also runs the experiment on shuffled labels, where no step should help, and redoes the t-test by hand.
python examples/negation_check.py compares negation marking on and off for ten short sentences.
python examples/balancing_check.py compares class weights with SMOTE and random over- and undersampling
(pip install imbalanced-learn); class weights did as well or better on all three datasets.
python examples/bert_compare.py compares the best TF-IDF setup of each run with CAMeLBERT-Mix (or other models
with --models) and writes paper/bert_results.csv. It needs pip install -e ".[bert]" and an internet
connection the first time.
python examples/camel_check.py compares the normalization steps with CAMeL Tools (pip install camel-tools). On
the three datasets the output is the same for all but 4 of 16,458 texts, and in those 4 AraPrepLab also removes
rare Quranic marks that CAMeL Tools keeps. CAMeL Tools is not a dependency because it installs torch and
transformers, which makes the tool much heavier to install offline.
Stand-alone app
For people without Python, build a folder that runs on its own:
pip install -e ".[app]"
python packaging/build_exe.py
The app is in dist/AraPrepLab/ (AraPrepLab.exe on Windows). GitHub Actions builds the Windows version for
every release tag and attaches it to the run.
Development
pip install -e ".[dev]"
pytest --cov=arapreplab.core --cov=arapreplab.io
python tools/check_app.py --quick
tools/check_app.py opens the app and presses every button by itself: each tab, cleaning step, model, feature
type, metric, design, export and error message. It reports PASS or FAIL for each. docs/testing.md lists what it
covers and the few things to check by hand.
GitHub Actions runs the tests on Windows and Linux, with pip (Python 3.10 and 3.12) and with conda, on every push.
Limitations
- Arabizi (Arabic written in Latin letters) is detected by the audit but not converted.
- The dialect steps are rule based, with short word lists. They do not identify which dialect a text is in.
- The experiment uses classical TF-IDF models. They only know the words in their training data. A model trained on the UCI tweets, for example, has never seen "ما بنصح" and labels "ما بنصح فيه أبداً" as positive, while the same pipeline trained on the Lebanese reviews labels it negative. Train on data from the same domain and dialect as the texts you want to label.
- The BERT check uses the model frozen, with a logistic regression on top. Fine-tuning the whole model usually scores higher, but needs a GPU and much more time, so it is not included.
- It is a single-user desktop app.
- On Linux, Arabic typed into the prediction box shows as separate letters, because Tk on Linux does not join Arabic letters. The prediction itself is not affected, and Windows displays it correctly.
License and citation
MIT License. See CITATION.cff for how to cite AraPrepLab. The released versions are archived on Zenodo: https://doi.org/10.5281/zenodo.24765355
Fatima Zeidan and Leen El Sakka, Lebanese American University.
Metadata
Release files for arapreplab 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arapreplab-0.1.2.tar.gz | 112.0 kB | Without provenance | Details for arapreplab-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arapreplab-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for arapreplab-0.1.2-py3-none-any.whl |
Total release size: 223.3 kB
Release files / arapreplab-0.1.2.tar.gz
| Download URL | arapreplab-0.1.2.tar.gz |
|---|---|
| Size | 112.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b0fb94358bd935a4d9658024b510b7c0bb3b266692b2921273af2bbb514cf32
|
|
BLAKE2b-256 checksum How to use checksums |
80d8d45f7549b53a36461bc6f75a947bd5bd05f489ef986a316ca2b9808a7082
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / arapreplab-0.1.2-py3-none-any.whl
| Download URL | arapreplab-0.1.2-py3-none-any.whl |
|---|---|
| Size | 111.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e2b2e6902b8a3a1f9447bda88d6f4969afb2ff5be9f302e02315cfc745e3f03
|
|
BLAKE2b-256 checksum How to use checksums |
38e69ad6049f5c575fad7265315c61bf8696374f25150c23a6b24d51cbb69755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for arapreplab 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.