def main(argv):
    """Main
    """

    parameters = process_arguments(argv)
    file_list = sed_eval.io.load_file_pair_list(parameters['file_list'])
    path = os.path.dirname(parameters['file_list'])

    data = []
    all_data = dcase_util.containers.MetaDataContainer()
    for file_pair in file_list:
        reference_event_list = sed_eval.io.load_event_list(
            os.path.abspath(os.path.join(path, file_pair['reference_file']))
        )

        estimated_event_list = sed_eval.io.load_event_list(
            os.path.abspath(os.path.join(path, file_pair['estimated_file']))
        )

        data.append({
            'reference_event_list': reference_event_list,
            'estimated_event_list': estimated_event_list
        })

        all_data += reference_event_list

    event_labels = all_data.unique_event_labels

    segment_based_metrics = sed_eval.sound_event.SegmentBasedMetrics(event_labels)
    event_based_metrics = sed_eval.sound_event.EventBasedMetrics(event_labels)

    for file_pair in data:
        segment_based_metrics.evaluate(
            file_pair['reference_event_list'],
            file_pair['estimated_event_list']
        )

        event_based_metrics.evaluate(
            file_pair['reference_event_list'],
            file_pair['estimated_event_list']
        )

    if parameters['output_file']:
        results = dcase_util.containers.DictContainer({
            'segment_based_metrics': segment_based_metrics.results(),
            'event_based_metrics': event_based_metrics.results()
        }).save(parameters['output_file'])

    else:
        print(segment_based_metrics)
        print(event_based_metrics)
Main