Skip to content
Snippets Groups Projects
Commit 4d8fb041 authored by vvye's avatar vvye
Browse files

Implement console arguments

parent 66c32055
No related branches found
No related tags found
No related merge requests found
import argparse
import dataset
import evaluation
import timeline_generation
......@@ -15,7 +17,10 @@ keywords_by_topic = {
}
def main():
def main(args):
eval_results = []
data = dataset.get_timeline17_dataset('data/in/timeline17/Data')
for topic in data.keys():
......@@ -23,16 +28,41 @@ def main():
gold_timelines = data[topic]['gold_timelines']
keywords = keywords_by_topic[topic]
eval_results[topic] = {gold_timeline_name: {} for gold_timeline_name in gold_timelines.keys()}
for gold_timeline_name, gold_timeline in gold_timelines.items():
print(f'Topic {topic}, gold timeline {gold_timeline_name}')
timeline = timeline_generation.make_timeline(articles, gold_timeline, keywords)
timeline_generation.print_timeline(timeline)
ar1_f, ar2_f = evaluation.evaluate(timeline, [gold_timeline])
date_f1 = evaluation.date_f1(timeline, gold_timeline)
print(f'{ar1_f},{ar2_f},{date_f1}')
if args.timeline_output_path:
print('output to file') # todo
if args.evaluate:
ar1_f, ar2_f = evaluation.evaluate(timeline, [gold_timeline])
date_f1 = evaluation.date_f1(timeline, gold_timeline)
eval_results.append({topic, gold_timeline_name, ar1_f, ar2_f, date_f1})
break
break
if args.evaluation_output_file:
print('output to file') # todo
if __name__ == '__main__':
main()
parser = argparse.ArgumentParser()
parser.add_argument('--timeline_output_path',
type=str,
help='a directory to save the generated timeline files '
'(if this argument is not present, timelines will only be printed to the console)')
parser.add_argument('--evaluate',
action='store_true',
help='whether to evaluate the timelines after generating them')
parser.add_argument('--evaluation_output_file',
type=str,
help='a file to save the evaluation output (only applies if the argument --evaluate is given)')
main(parser.parse_args())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment