Skip to main content

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:

  1. Compression: It must collapse noisy variations of words into a single representation to reduce the feature space.
  2. 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/CR AES = (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 word w

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: TfidfVectorizer is 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

normeval-0.1.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

normeval-0.1.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file normeval-0.1.3.tar.gz.

File metadata

  • Download URL: normeval-0.1.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for normeval-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f3311dfb764ad80ea8235babfd95824bb97428fc061c5e593e93b60529ddd84c
MD5 9f28972ad9fc975af576e3654cd4bdbe
BLAKE2b-256 aaa125ec2e7142087c7ce560fd73378a1ffb5678566d8c50e0739a9cee7adbfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for normeval-0.1.3.tar.gz:

Publisher: ci_cd.yml on abkafi1234/normeval

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file normeval-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: normeval-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for normeval-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e763830128c118a9d8d1cf3ba8cc55211ad52fb4c5a107777f24db7851085f56
MD5 ab61d1d892a83ae4be201803c23d7bdc
BLAKE2b-256 c5d9f421d17287798c8792fe135f446a109b77c2971238a36de2866477fa8468

See more details on using hashes here.

Provenance

The following attestation bundles were made for normeval-0.1.3-py3-none-any.whl:

Publisher: ci_cd.yml on abkafi1234/normeval

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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