Ejemplo n.º 1
0
Output:
    Text file of replaced output using user text

Parameters:
    -author:    name of author to convert style to
    -input:     user input  
    -output:    output text
    -fast:      non-Lesk, non-POS tagging mode
"""

from write_like import WriteLike
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-author', '--author', '-a', '--a', type=str, help='name of author', required=True)
    parser.add_argument('-input', '--input', '-in', '--in', '-i', '--i', type=str, help='user input file',
                        required=True)
    parser.add_argument('-output', '--output', '-out', '--out', '-o', '--o', type=str, help='filename of output',
                        required=True)
    parser.add_argument('-fast', '--fast', '-nolesk', '--nolesk', '-f', '--f', action='store_true', required=False)
    args = parser.parse_args()

    wl = WriteLike(args.author)
    
    if args.fast:
        wl.style_convert(args.input, args.output)
    else:
        wl.style_convert_lesk(args.input, args.output)
Ejemplo n.º 2
0
	# testing
	print "Starting tests..."

	for test_file in test_files:

		print "\tCurrently testing", test_file
		f.write('====\nFile: ' + test_file + '\n====\n')

		for author in authors:
			temp_array_nolesk = []
			temp_array_lesk = []

			for iteration in xrange(args.iterations):

				wl = WriteLike(author)

				wl.style_convert(infile_name = test_file, outfile_name = o_file)
				result = my_diff(test_file, o_file, args.output_filename, author, False)
				temp_array_nolesk.append(result)

				wl.style_convert_lesk(infile_name = test_file, outfile_name = o_file)
				result = my_diff(test_file, o_file, args.output_filename, author, True)
				temp_array_lesk.append(result)

			f.write('Author:' + author + '\t + (no lesk):' + str(1.0 * sum([plus[0] for plus in temp_array_nolesk])/len(temp_array_nolesk)) + '\n' )
			f.write('Author:' + author + '\t - (no lesk):' + str(1.0 * sum([minus[1] for minus in temp_array_nolesk])/len(temp_array_nolesk)) + '\n' )

			f.write('Author:' + author + '\t + (lesk)   :' + str(1.0 * sum([plus[0] for plus in temp_array_lesk])/len(temp_array_lesk)) + '\n')
			f.write('Author:' + author + '\t - (lesk)   :' + str(1.0 * sum([minus[1] for minus in temp_array_lesk])/len(temp_array_lesk)) + '\n' )