def run_single_eval(nlp, loading_time, print_name, text_path, gold_ud, tmp_output_path, out_file, print_header,<EOL>check_parse, print_freq_tasks):
with text_path.open(mode='<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>flat_text = f.read()<EOL><DEDENT>tokenization_start = time.time()<EOL>texts = split_text(flat_text)<EOL>docs = list(nlp.pipe(texts))<EOL>tokenization_end = time.time()<EOL>tokenization_time = tokenization_end - tokenization_start<EOL>tokens_per_s = int(len(gold_ud.tokens) / tokenization_time)<EOL>print_header_1 = ['<STR_LIT:date>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>print_string_1 = [str(datetime.date.today()), text_path.name, len(gold_ud.tokens),<EOL>print_name, "<STR_LIT>" % loading_time, "<STR_LIT>" % tokenization_time, tokens_per_s]<EOL>with tmp_output_path.open(mode="<STR_LIT:w>", encoding="<STR_LIT:utf8>") as tmp_out_file:<EOL><INDENT>write_conllu(docs, tmp_out_file)<EOL><DEDENT>with tmp_output_path.open(mode="<STR_LIT:r>", encoding="<STR_LIT:utf8>") as sys_file:<EOL><INDENT>sys_ud = conll17_ud_eval.load_conllu(sys_file, check_parse=check_parse)<EOL><DEDENT>tmp_output_path.unlink()<EOL>scores = conll17_ud_eval.evaluate(gold_ud, sys_ud, check_parse=check_parse)<EOL>eval_headers = EVAL_PARSE<EOL>if not check_parse:<EOL><INDENT>eval_headers = EVAL_NO_PARSE<EOL><DEDENT>for score_name in eval_headers:<EOL><INDENT>score = scores[score_name]<EOL>print_string_1.extend(["<STR_LIT>" % score.precision,<EOL>"<STR_LIT>" % score.recall,<EOL>"<STR_LIT>" % score.f1])<EOL>print_string_1.append("<STR_LIT:->" if score.aligned_accuracy is None else "<STR_LIT>" % score.aligned_accuracy)<EOL>print_string_1.append("<STR_LIT:->" if score.undersegmented is None else "<STR_LIT>" % score.under_perc)<EOL>print_string_1.append("<STR_LIT:->" if score.oversegmented is None else "<STR_LIT>" % score.over_perc)<EOL>print_header_1.extend([score_name + '<STR_LIT>', score_name + '<STR_LIT>', score_name + '<STR_LIT>', score_name + '<STR_LIT>',<EOL>score_name + '<STR_LIT>', score_name + '<STR_LIT>'])<EOL>if score_name in print_freq_tasks:<EOL><INDENT>print_header_1.extend([score_name + '<STR_LIT>', score_name + '<STR_LIT>',<EOL>score_name + '<STR_LIT>', score_name + '<STR_LIT>'])<EOL>d_under_words = get_freq_tuples(score.undersegmented, PRINT_TOTAL)<EOL>d_under_shapes = get_freq_tuples([word_shape(x) for x in score.undersegmented], PRINT_TOTAL)<EOL>d_over_words = get_freq_tuples(score.oversegmented, PRINT_TOTAL)<EOL>d_over_shapes = get_freq_tuples([word_shape(x) for x in score.oversegmented], PRINT_TOTAL)<EOL>print_string_1.append(<EOL>str({k: v for k, v in d_under_words if v > PRINT_FREQ}).replace("<STR_LIT:;>", "<STR_LIT>"))<EOL>print_string_1.append(<EOL>str({k: v for k, v in d_under_shapes if v > PRINT_FREQ}).replace("<STR_LIT:;>", "<STR_LIT>"))<EOL>print_string_1.append(<EOL>str({k: v for k, v in d_over_words if v > PRINT_FREQ}).replace("<STR_LIT:;>", "<STR_LIT>"))<EOL>print_string_1.append(<EOL>str({k: v for k, v in d_over_shapes if v > PRINT_FREQ}).replace("<STR_LIT:;>", "<STR_LIT>"))<EOL><DEDENT><DEDENT>if print_header:<EOL><INDENT>out_file.write('<STR_LIT:;>'.join(map(str, print_header_1)) + '<STR_LIT:\n>')<EOL><DEDENT>out_file.write('<STR_LIT:;>'.join(map(str, print_string_1)) + '<STR_LIT:\n>')<EOL>
Run an evaluation of a model nlp on a certain specified treebank