How to use the errant.load function in errant

To help you get started, we’ve selected a few errant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisjbryant / errant / errant / commands / parallel_to_m2.py View on Github external
def main():
#    pr = cProfile.Profile()
#    pr.enable()

    # Parse command line args
    args = parse_args()
    print("Loading resources...")
    # Load Errant
    annotator = errant.load("en")
    # Open output m2 file
    out_m2 = open(args.out, "w")

    print("Processing parallel files...")
    # Process an arbitrary number of files line by line simultaneously. Python 3.3+
    # See https://tinyurl.com/y4cj4gth
    with ExitStack() as stack:
        in_files = [stack.enter_context(open(i)) for i in [args.orig]+args.cor]
        # Process each line of all input files
        for line in zip(*in_files):
            # Get the original and all the corrected texts
            orig = line[0].strip()
            cors = line[1:]
            # Skip the line if orig is empty
            if not orig: continue
            # Parse orig with spacy

errant

The ERRor ANnotation Toolkit (ERRANT). Automatically extract and classify edits in parallel sentences.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages