示例#1
0
def read_batchscore_config(config_file):
    with open(config_file) as f:
        config_yaml = f.read()
    config = yaml.load(config_yaml)

    # List of dataset names
    datasets = config['datasets']

    # List of scoring runs with the run id, scorer, and params.
    # Initialize the scorers
    scorers = []
    scs = config['scorers']
    ids = set()
    for sc in scs:
        batchscore_id = sc['id']
        if batchscore_id in ids:
            raise ValueError("Duplicate scorer id: %s" % batchscore_id)
        ids.add(batchscore_id)
        scorer_name = sc['scorer']
        if 'params' in sc:
            params = sc['params']
        else:
            params = {}
        scorer = get_scorer(scorer_name, **params)
        scorer.set_output_id(batchscore_id)
        scorers.append(scorer)
    return datasets, scorers
示例#2
0
文件: score.py 项目: jwayne/conseval
def main():
    args = parse_args()

    # Get scorer
    scorer = get_scorer(args.scorer_name, **args.scorer_params)

    # Get alignment and supplementary inputs
    alignment = Alignment(args.align_file, **args.align_params)

    # Score
    scores = scorer.score(alignment)

    # Output
    header = list_scorer_params(scorer)
    scores_cols = [scores]
    write_scores(alignment, scores_cols, [args.scorer_name], header=header, f=sys.stdout)
    if args.draw:
        draw_scores(alignment, scores_cols, [args.scorer_name])