Skip to main content

GECLens

Error-type-targeted evaluation of grammatical error correction (GEC) systems.

tests python license

Overall F0.5 hides how a system handles a single kind of error. Subject–verb agreement, articles, prepositions and tense each make up only a few per cent of all edits. GECLens answers two questions for any ERRANT error type:

  1. Does the system fix these errors? Type F0.5, type-only F0.5, sentence-level detection and correction success.
  2. What does it break while trying? Over-correction on sentences the references leave unchanged.

Every measure comes with bootstrap confidence intervals and paired significance tests (approximate randomisation with Holm correction), for any number of systems. Results are written as CSV, Markdown and LaTeX tables and as figures.

GECLens builds on ERRANT for alignment and edit typing. Its edit-level scores are identical to errant_compare. This is checked in the test suite.


Installation

pip install geclens            # or, from source: pip install -e .
python -m spacy download en_core_web_sm

Requirements: Python 3.9–3.12, ERRANT 3.0.2, spaCy 3.4–3.7 with en_core_web_sm, NumPy, Matplotlib and PyYAML. GECLens runs on Linux, macOS and Windows.

Quick start (toy data included)

cd examples/toy
geclens run config.yaml          # about 5 seconds

This scores three toy systems on 30 sentences for three error types and writes results/. The toy data were written by the GECLens authors and are released under CC0.

System Overall F0.5 Type F0.5 Type-only F0.5 Detection F1 Success Over-corr.
careful 0.882 0.972 0.972 0.933 87.5% 0.0%
eager 0.649 0.987 0.987 0.968 93.8% 100.0%
cautious 0.312 0.435 0.435 0.222 12.5% 0.0%

eager fixes agreement errors as well as careful, but it also rewrites every correct sentence. Type-level F0.5 alone would not show this.

What GECLens measures

For an error-type selector T (for example R:VERB:SVA):

Measure Definition
overall ERRANT precision, recall and F0.5 over all edits
type ERRANT P/R/F0.5 for edits of type T, for the annotator ERRANT selects per sentence (the one that maximises overall F0.5)
type_only P/R/F0.5 after restricting hypothesis and reference edits to T, so the annotator choice depends on T edits only. Use it to compare systems that make different amounts of other edits.
detection Sentence-level P/R/F1 for "the sentence contains a T error"
success Share of T-positive sentences where every T edit of at least one annotator was produced exactly
overcorrection Share of unedited reference sentences that the system changed (whitespace and quote style ignored)
change_rate Share of all sentences the system changed

Subsets (geclens subset): positive (some annotator made a T edit), positive_all, unedited (no annotator made any edit), unedited_any, and other.

Error-type selectors:

  • an exact type (R:VERB:SVA);
  • a category, which matches its M/R/U variants (DET);
  • a pattern (R:VERB*);
  • a comma-separated list (PREP,DET).

Command line

# subsets and reference statistics
geclens subset  --ref ref.m2 --type R:VERB:SVA --out subsets.json

# scores with 95% bootstrap confidence intervals
geclens score   --src src.txt --ref ref.m2 --type DET \
                --hyp sysA=a.txt sysB=b.txt --ci 2000 --out-dir results

# paired approximate randomisation, Holm-adjusted, every system vs a baseline
geclens compare --src src.txt --ref ref.m2 --type PREP --hyp sysA=a.txt sysB=b.txt base=c.txt \
                --baseline base --measures type_only overcorrection --shuffles 10000

# system x error-type heatmap of ERRANT F0.5
geclens profile --src src.txt --ref ref.m2 --hyp a.txt b.txt c.txt --group category --top 12

# everything from one configuration file
geclens run config.yaml

Inputs:

  • --src: tokenised source sentences, one per line.
  • --ref: an ERRANT-typed reference M2 file. If you only have corrected text, create it with errant_parallel -orig src.txt -cor ref1.txt [ref2.txt ...] -out ref.m2.
  • --hyp: system outputs as text (one sentence per line) or as ready-made .m2 files.

Hypothesis M2 files are built once with ERRANT and cached.

Python API

from geclens import score_many, bootstrap_ci, compare_systems, profile_table, evaluate

scores = score_many("src.txt", "ref.m2", {"A": "a.txt", "B": "b.txt"}, selector="R:VERB:SVA")
scores["A"].metrics["type_only"]                    # {'tp':…, 'fp':…, 'fn':…, 'P':…, 'R':…, 'F0.5':…}
bootstrap_ci(scores["A"], resamples=2000)           # {'overall': (lo, hi), 'type': …, …}
compare_systems(scores, ["type_only", "overcorrection"], baseline="B")

evaluate("src.txt", "ref.m2", {"A": "a.txt", "B": "b.txt"}, selector="PREP", out_dir="results")

Configuration file

source: src.txt
reference: ref.m2
out_dir: results
selectors: [R:VERB:SVA, PREP, DET]      # one evaluation per selector
systems: {careful: careful.txt, eager: eager.txt, cautious: cautious.txt}
statistics: {bootstrap_resamples: 2000, shuffles: 10000, measures: [type_only, overcorrection], baseline: cautious, seed: 13}
profile: {group: category, top: 12}

Output files

File Content
scores.csv / .md / .tex One row per system; the Markdown and LaTeX tables include 95% CIs
<system>.json All measures and per-type ERRANT counts
confidence_intervals.json Bootstrap intervals
comparisons.md / .json Differences, paired-bootstrap CIs, p-values and Holm-adjusted p-values
scatter.png Type-only F0.5 against over-correction
profile.png / .json System × error-type heatmap
subsets.json, reference_stats.json Subset indices and reference statistics

Correctness

  • Hypothesis M2 files are byte-identical to errant_parallel, overall and per-type TP/FP/FN equal errant_compare -cat 3, and the per-sentence counts equal those of the annotator that errant_compare -v reports as chosen for each sentence (see tests/test_score.py and tests/test_edge_cases.py). Check this on your own data with python scripts/check_against_errant.py src.txt ref.m2 sys1.txt [sys2.txt ...].
  • A hand-built case with two annotators covers missed, unnecessary and replacement edits, two target edits in one sentence, an unedited sentence and an empty subset; expected values were worked out by hand.
  • Statistical routines are tested on known cases: identical systems give p = 1, Holm values are checked by hand, and bootstrap intervals contain the point estimate.
  • The CI runs the suite on Python 3.9–3.12.
pip install -e ".[dev]" && pytest

Citation

If you use GECLens, please cite the software (see CITATION.cff):

P. Gautam, J. S. Thakur, A. Mishra. GECLens: A Python toolkit for error-type-targeted evaluation of grammatical error correction systems. Version 1.0.0, 2026. https://github.com/prakhargautam-ggits/GECLens

Licence and support

Metadata

Release files for geclens 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geclens 1.0.0
File Size Uploaded Provenance Actions
geclens-1.0.0.tar.gz 28.8 kB With provenance Details for geclens-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geclens 1.0.0
File Interpreter ABI Platform Actions
geclens-1.0.0-py3-none-any.whl Python 3 none any Details for geclens-1.0.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / geclens-1.0.0.tar.gz

Download URL geclens-1.0.0.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
19ae95cc75cfbdaf71692e8d264ea7608961bc913ece40d3f2e0a4f0da3ed7fd
BLAKE2b-256 checksum
How to use checksums
9d7052b17c4747052d5a2356b159edfa6fd98fef43dd45a6e9fdb19d4126d209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / geclens-1.0.0-py3-none-any.whl

Download URL geclens-1.0.0-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a173ed69906e811753d6c46c5c6c87e2c4408cadd3fe339b006fd10236e5f5a5
BLAKE2b-256 checksum
How to use checksums
b4fa3216e3c2801c6a95a2f4c560fdc44e81ab7893771c5279175cca63bd7599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for geclens 1.0.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geclens-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page