Skip to main content

GECOMMON: A common toolkit for Grammatical Error Correcion

You can install from PyPi:

pip install gecommon
python -m spacy download en_core_web_sm

Or, from github:

git clone https://github.com/gotutiyan/gecommon.git
cd gecommon
pip install -e ./
python -m spacy download en_core_web_sm

Features

  • gecommon.CachedERRANT: Class to use ERRANT faster by caching.
  • gecommon.Parallel (docs): Class to handle parallel and M2 format in the same interface.
  • gecommon.utils.apply_edits: A function to apply an errant.edit.Edit sequence to a sentence.

Use cases

gecommon.CachedERRANT

You can replace parse() and annotate() of original ERRANT with .extract_edits().
This also caches the results of parse() and annotate(), thus it works faster when processing the same sentence or parallel sentence two or more times.

from gecommon import CachedERRANT
errant = CachedERRANT()
edits = errant.extract_edits('This is a sample sentences .', 'These are sample sentences .')
print(edits)

gecommon.Parallel

  • The most important feature is the ability to handle both M2 and parallel formats in the same interface.
from gecommon import Parallel
# If the input is M2 format
gec = Parallel.from_m2(
    m2=<a m2 file path>,
    ref_id=0
)
# If parallel format
gec = Parallel.from_parallel(
    src=<a src file path>,
    trg=<a trg file path>
)
# After that, you can handle the input data in the same interface.
assert gec.srcs is not None
assert gec.trgs is not None
assert gec.edits_list is not None
  • To generate error detection labels
    • You can use not only binary labels but also 4-class, 25-class, 55-class like [Yuan+ 21].
from gecommon import Parallel
gec = Parallel.from_demo()
# Sentence-level labels
print(gec.ged_labels_sent()) 
# [['INCORRECT'], ['INCORRECT'], ['CORRECT']]

# Token-level labels
print(gec.ged_labels_token(mode='cat3'))
# [['CORRECT', 'R:VERB:SVA', 'R:SPELL', 'CORRECT', 'CORRECT'],
# ['CORRECT', 'CORRECT', 'U:VERB', 'CORRECT', 'R:ORTH', 'R:ORTH', 'CORRECT', 'CORRECT'],
# ['CORRECT', 'CORRECT', 'CORRECT', 'CORRECT', 'CORRECT']]
from gecommon import Parallel
gec = Parallel.from_demo()
for edits in gec.edits_list:
    for e in edits:
        print(e.o_start, e.o_end, e.c_str)
    print('---')

# 1 2 is
# 2 2 a
# 2 3 grammatical
# ---
# 2 3 
# 4 6 grammatical
# ---
# ---

Metadata

Release files for gecommon 0.2.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 gecommon 0.2.0
File Size Uploaded
gecommon-0.2.0.tar.gz 23.9 MB Details

Built distribution (wheel)

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

Total release size: 23.9 MB

Release files / gecommon-0.2.0.tar.gz

Download URL gecommon-0.2.0.tar.gz
Size 23.9 MB
Tags Source
SHA-256 checksum
How to use checksums
6f35c9f88fa2903fed37128eb0ebcac49f1954fd3e53f14c4db137da15aa7498
BLAKE2b-256 checksum
How to use checksums
af62e3125c4387bbdc605307f21236d6a9adac5b639210c89cb8db234a5d0663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release files / gecommon-0.2.0-py3-none-any.whl

Download URL gecommon-0.2.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73fc473a484fd3b5758f77aae4c71ed4c60f76a2085160e8bf33aa08163672e3
BLAKE2b-256 checksum
How to use checksums
828d785cbae78665b5e7bddb6ac07158be0f62eebab185192efa42abf8af6e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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