@@ -0,0 +1,1324 @@
+from os.path import *%0Aimport argparse%0Aimport gate%0A%0A%0Aclass InputError(Exception):%0A    pass%0A%0Aparser = argparse.ArgumentParser(%0A    # TODO: update desc%0A    description=%22Writes the plain text used within %22%0A    %22a GATE document to a file%22%0A)%0Aparser.add_argument(%0A    %22-i%22,%0A    %22--input-file%22,%0A    dest=%22input_file%22,%0A    required=%22true%22,%0A    help=%22GATE annotation file%22%0A)%0Aparser.add_argument(%0A    %22-o%22,%0A    %22--output-file%22,%0A    dest=%22output_file%22,%0A    help=%22destination file for text output. %22%0A    %22Default is '%3Cfilename%3E.textraction'.%22%0A)%0A%0Aargs = parser.parse_args()%0Aannotation_file = gate.AnnotationFile(args.input_file)%0Atext = annotation_file.get_text()%0A%0Aif args.output_file: output_file = abspath(args.output_file)%0Aelse: output_file = (%0A    splitext(%0A        abspath(args.input_file)%0A    )%5B0%5D + %22.textraction%22%0A)%0A%0Aif isfile(output_file):%0A    while True:%0A        response = input(%0A            %22Overwrite file '%7B%7D'? y/N --%3E %22.format(output_file)%0A        ).lower()%0A        if response == %22y%22:%0A            break%0A        elif (response == %22n%22) or (response == %22%22):%0A            print(%22Skipping file '%7B%7D'%22.format(output_file))%0A            quit()%0A        else: print(%22Error: '%7B%7D' not recognized.%22.format(response))%0A%0Awith open(output_file, %22w%22) as destination:%0A    destination.write(text)%0A%0Aprint(%22File written: '%7B%7D'%22.format(output_file))%0A

Add textractor.py for extracting document text