A scientific suite for evaluating text normalization algorithms.
Project description
normeval: Scientific Evaluation Suite for Text Normalization
normeval is a robust, mathematically grounded Python framework for evaluating text normalization algorithms. It goes beyond simple string matching by combining semantic preservation, vocabulary compression, character-level fidelity, and statistically rigorous downstream impact analysis.
🔬 Motivation: Why do we need this?
Evaluating text normalization (such as stemming, lemmatization, spell-correction, or noise reduction) is traditionally a fragmented process. Researchers often rely solely on downstream accuracy, which is highly susceptible to dataset bias and random initialization.
A "good" normalization algorithm must balance two competing objectives:
- Compression: It must collapse noisy variations of words into a single representation to reduce the feature space.
- Preservation: It must not destroy the underlying semantic meaning or map unrelated words together.
normeval provides a holistic, unified suite to measure this balance, ensuring your normalization techniques are rigorously tested before being deployed in NLP pipelines.
📦 Installation
Install directly from PyPI:
pip install normeval
🚀 Quick StartPythonfrom normeval import NormalizationEvaluator
from sklearn.linear_model import LogisticRegression
from sentence_transformers import SentenceTransformer
# 1. Your parallel datasets
texts_original = [
"The cats are running!!",
"A running cat..."
]
texts_normalized = [
"the cat run",
"a run cat"
]
labels = [1, 0]
# 2. Define your models
classifiers = [LogisticRegression()]
embedder = SentenceTransformer('all-MiniLM-L6-v2')
# 3. Initialize Evaluator
evaluator = NormalizationEvaluator(
texts_original,
texts_normalized,
labels=labels,
classifiers=classifiers,
embedding_model=embedder
)
# 4. Run the full suite
results = evaluator.evaluate_all(lang="Global")
print(results)
📊 Metrics (Function Deep-Dive)
normeval evaluates text normalization across macroscopic, semantic, and downstream dimensions.
1. Compression Ratio (CR)
- Function:
calculate_cr() - What it is: Measures the macroscopic reduction in vocabulary size.
- The Math:
CR = |V_original| / |V_normalized| - Interpretation:
- CR = 1.0 → No compression occurred (bijective mapping).
- CR > 1.0 → Multiple noisy variants successfully collapsed into fewer normalized forms.
2. Information Retention Score (IRS)
- Function:
calculate_irs(batch_size=32) - What it is: Measures how much semantic meaning survived the normalization process.
- Mechanism: Converts both original and normalized texts into dense vector embeddings and computes paired cosine similarity.
- Interpretation:
- Range: [-1, 1]
- A score near 1.0 indicates semantic meaning was preserved successfully.
3. Algorithm Effectiveness Score (AES)
- Function:
calculate_aes(cr, irs) - What it is: A harmonic mean balancing Compression (CR) and Preservation (IRS).
- The Math:
VRG = 1-1/CRAES = (2 × IRS × VRG) / (IRS + VRG) - Interpretation: Punishes algorithms that are:
- Too aggressive (High CR, low IRS)
- Too passive (High IRS, low CR)
4. Average Normalized Levenshtein Distance (ANLD)
- Function:
calculate_anld() - What it is: A micro-level safety metric measuring character-level fidelity.
- The Math:
ANLD = (1 / |V|) Σ [ LD(w, σ(w)) / |w| ] - Where:
LD= Levenshtein Distanceσ(w)= normalized form of wordw
5. Model Performance Delta (MPD) & Statistical Significance
- Function:
calculate_mpd(n_splits=5, average_method='weighted') - What it is: Measures the impact on classification performance using Stratified N-Fold CV.
- Statistical Rigor: Applies the Wilcoxon Signed-Rank Test across CV folds (p < 0.05).
- Leakage Prevention:
TfidfVectorizeris fit inside each CV fold to strictly prevent train/test leakage.
🏗️ Project Goals
Reproducible evaluation pipelines.
Statistically grounded benchmarking.
Semantic preservation analysis.
Language-agnostic evaluation.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, open an issue first to discuss proposed improvements.
📄 License
This project is licensed under the MIT License.
⭐ Citation If you use normeval in your research, please cite: underway
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
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 normeval-0.1.4.tar.gz.
File metadata
- Download URL: normeval-0.1.4.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
155eaf5c75d34097409435e9307a4388bfc25bb0c0834ba0ba7b78159748e3b3
|
|
| MD5 |
e24b8a5cb3a359e15d1ea160ad9591ec
|
|
| BLAKE2b-256 |
76c8a3cfa5041b0b1be29322240a4b5828370ced6ac6fdd3c1c68f77262b74f0
|
Provenance
The following attestation bundles were made for normeval-0.1.4.tar.gz:
Publisher:
ci_cd.yml on abkafi1234/normeval
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
normeval-0.1.4.tar.gz -
Subject digest:
155eaf5c75d34097409435e9307a4388bfc25bb0c0834ba0ba7b78159748e3b3 - Sigstore transparency entry: 1766331480
- Sigstore integration time:
-
Permalink:
abkafi1234/normeval@be18ce7299c311dde5b3c8c378de9a21ac299886 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/abkafi1234
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci_cd.yml@be18ce7299c311dde5b3c8c378de9a21ac299886 -
Trigger Event:
push
-
Statement type:
File details
Details for the file normeval-0.1.4-py3-none-any.whl.
File metadata
- Download URL: normeval-0.1.4-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b62aa08a54167d2eb7188eec5a3f9c29f32b43dcdf5a3040aaf4fb1b13f6c6ab
|
|
| MD5 |
10c2cf69d688eef3f07ccd1385970950
|
|
| BLAKE2b-256 |
1c2e74d503ec8b524ec187d618f3c7ef58129acca0505f80f0998f4d8331c553
|
Provenance
The following attestation bundles were made for normeval-0.1.4-py3-none-any.whl:
Publisher:
ci_cd.yml on abkafi1234/normeval
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
normeval-0.1.4-py3-none-any.whl -
Subject digest:
b62aa08a54167d2eb7188eec5a3f9c29f32b43dcdf5a3040aaf4fb1b13f6c6ab - Sigstore transparency entry: 1766332242
- Sigstore integration time:
-
Permalink:
abkafi1234/normeval@be18ce7299c311dde5b3c8c378de9a21ac299886 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/abkafi1234
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci_cd.yml@be18ce7299c311dde5b3c8c378de9a21ac299886 -
Trigger Event:
push
-
Statement type: