Jann/process_novel_first_lines.py
def process_novel_first_lines(args):
    """Main run function for processing the Novel First Lines dataset."""

    # Crowdsourced lines file.
    crowdsourced_lines_file = os.path.join(args.infile_path, 'crowdsourced_all.txt')
    tf.logging.info(
        'Novel First Lines crowdsourced_lines_path: {}'.format(crowdsourced_lines_file))

    lines = []
    try:
        with open(crowdsourced_lines_file, encoding='iso-8859-1') as f:
            for line in f:
                line = filter_line(line)
                if line is not None:
                    lines.append(line + '\t' + line)
    except FileNotFoundError as error:
        tf.logging.error(error)
        tf.logging.error(tf.logging.ERROR, 'File not found.')
        sys.exit(0)
    tf.logging.info("Found {} unique input lines.".format(len(lines)))
    lines = sorted(lines)

    with open(args.outfile, 'w', encoding='iso-8859-1') as f:
        for item in lines:
            f.write("%s\n" % item)
        tf.logging.info(
            'Wrote {} lines to {}.'.format(len(lines), args.outfile))
    return True
Main run function for processing the Novel First Lines dataset.
Main run function for processing the Novel First Lines dataset.
Main run function for processing the Novel First Lines dataset .
def process_novel_first_lines(args):
    crowdsourced_lines_file = os.path.join(args.infile_path, 'crowdsourced_all.txt')
    tf.logging.info(
        'Novel First Lines crowdsourced_lines_path: {}'.format(crowdsourced_lines_file))
    lines = []
    try:
        with open(crowdsourced_lines_file, encoding='iso-8859-1') as f:
            for line in f:
                line = filter_line(line)
                if line is not None:
                    lines.append(line + '\t' + line)
    except FileNotFoundError as error:
        tf.logging.error(error)
        tf.logging.error(tf.logging.ERROR, 'File not found.')
        sys.exit(0)
    tf.logging.info("Found {} unique input lines.".format(len(lines)))
    lines = sorted(lines)
    with open(args.outfile, 'w', encoding='iso-8859-1') as f:
        for item in lines:
            f.write("%s\n" % item)
        tf.logging.info(
            'Wrote {} lines to {}.'.format(len(lines), args.outfile))
    return True
def process_novel_first_lines ( args ) : crowdsourced_lines_file = os . path . join ( args . infile_path , 'crowdsourced_all.txt' ) tf . logging . info ( 'Novel First Lines crowdsourced_lines_path: {}' . format ( crowdsourced_lines_file ) ) lines = [ ] try : with open ( crowdsourced_lines_file , encoding = 'iso-8859-1' ) as f : for line in f : line = filter_line ( line ) if line is not None : lines . append ( line + '\t' + line ) except FileNotFoundError as error : tf . logging . error ( error ) tf . logging . error ( tf . logging . ERROR , 'File not found.' ) sys . exit ( 0 ) tf . logging . info ( "Found {} unique input lines." . format ( len ( lines ) ) ) lines = sorted ( lines ) with open ( args . outfile , 'w' , encoding = 'iso-8859-1' ) as f : for item in lines : f . write ( "%s\n" % item ) tf . logging . info ( 'Wrote {} lines to {}.' . format ( len ( lines ) , args . outfile ) ) return True
Main run function for processing the Novel First Lines dataset.
Main run function for processing the Novel First Lines dataset .
"""Main run function for processing the Novel First Lines dataset.""" # Crowdsourced lines file.
args