コード例 #1
0
        elif opt in ("-m", "--sim_measures"):
            sim_measures = val.split(",")
        elif opt in ("-s", "--space"):
            spaces = val.split(",")
        elif opt in ("-c", "--columns"):
            columns = val.split(",")
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(sim_measures, "Similarity measures required", usage)
    utils.assert_option_not_none(columns, "Columns to be read from input file required", usage)

    if not in_dir is None:
        compute_sim_batch(in_file, columns, out_dir, sim_measures, in_dir)
    else:
        utils.assert_option_not_none(spaces, "Semantic space file required", usage)
        compute_sim(in_file, columns, out_dir, sim_measures, spaces)


if __name__ == '__main__':
    main(sys.argv)
コード例 #2
0
            in_format = val
        elif opt == "--output_format":
            out_format = val
        elif opt == "--core_in_dir":
            core_in_dir = val
        elif opt == "--core_filter":
            core_filter = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file_prefix, "Input file prefix required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(in_format, "Input file format required", usage)

    gz = eval(gz)
    utils.assert_bool(gz, "--gz value must be True/False", usage)

    if not core_in_dir is None:
        build_space_batch(in_file_prefix, in_format, out_dir, out_format, core_in_dir, core_filter, gz)
    else:
        utils.assert_option_not_none(core_space_file, "Input file required", usage)
        build_space(in_file_prefix, in_format, out_dir, out_format, core_space_file, gz)


if __name__ == "__main__":
    main(sys.argv)
コード例 #3
0
        elif opt in ("-c", "--columns"):
            columns = val.split(",")
        elif opt == "--in_dir":
            in_dir = val
        elif opt == "--filter":
            filter_ = val    
        elif opt in ("-l", "--log"):
            log_file = val 
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)
            
    log_utils.config_logging(log_file)
    
    utils.assert_option_not_none(corr_measures, "Correlation measures required", usage)
    utils.assert_option_not_none(columns, "Columns to be read from input file required", usage)
    
    if len(columns) != 2:
        raise ValueError("Columns (-c) field should contain two comma-separated integers (e.g. -c 3,4)")
            
    if not in_dir is None:
        evaluate_sim_batch(in_dir, columns, corr_measures, filter_)
    else:
        utils.assert_option_not_none(in_file, "Input file required", usage)
        evaluate_sim(in_file, columns, corr_measures)
   
if __name__ == '__main__':
    main(sys.argv)
    
コード例 #4
0
            columns = val.split(",")
        elif opt == "--in_dir":
            in_dir = val
        elif opt == "--filter":
            filter_ = val
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(corr_measures,
                                 "Correlation measures required", usage)
    utils.assert_option_not_none(
        columns, "Columns to be read from input file required", usage)

    if len(columns) != 2:
        raise ValueError(
            "Columns (-c) field should contain two comma-separated integers (e.g. -c 3,4)"
        )

    if not in_dir is None:
        evaluate_sim_batch(in_dir, columns, corr_measures, filter_)
    else:
        utils.assert_option_not_none(in_file, "Input file required", usage)
        evaluate_sim(in_file, columns, corr_measures)

コード例 #5
0
ファイル: train_composition.py プロジェクト: totonac/dissect
            param = val
        elif opt == "--lambda_range":
            param_range = val.split(",")
        elif opt == "--export_params":
            export_params = val
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(model, "Model to be trained required", usage)
    utils.assert_option_not_none(arg_space,
                                 "Argument space(s) file(s) required", usage)
    utils.assert_option_not_none(phrase_space, "Phrase space file required",
                                 usage)

    crossvalidation = eval(crossvalidation)
    intercept = eval(intercept)
    utils.assert_bool(intercept, "intercept must be True/False", usage)
    utils.assert_bool(crossvalidation, "crossvalidation must be True/False",
                      usage)

    export_params = eval(export_params)
    utils.assert_bool(export_params, "export_params must be True/False", usage)
コード例 #6
0
            beta = val 
        elif opt == "--lambda":
            lambda_ = val 
        elif opt == "--output_format":
            out_format = val 
        elif opt in ("-l", "--log"):
            log_file = val 
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)
            
    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)    
    utils.assert_xor_options(model, trained_model, "(Only) one of model name (-m) or file of model object (--load_model) are required!", usage)
    utils.assert_option_not_none(arg_space, "Argument space(s) file(s) required", usage)

    if not alpha is None:
        alpha = float(alpha)
    if not beta is None:    
        beta = float(beta)
    if not lambda_ is None:
        lambda_ = float(lambda_)     
        
    apply_model(in_file, out_dir, model, trained_model, arg_space,
                alpha, beta, lambda_, out_format)
    
    
コード例 #7
0
ファイル: apply_composition.py プロジェクト: totonac/dissect
            beta = val
        elif opt == "--lambda":
            lambda_ = val
        elif opt == "--output_format":
            out_format = val
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_xor_options(
        model, trained_model,
        "(Only) one of model name (-m) or file of model object (--load_model) are required!",
        usage)
    utils.assert_option_not_none(arg_space,
                                 "Argument space(s) file(s) required", usage)

    if not alpha is None:
        alpha = float(alpha)
    if not beta is None:
        beta = float(beta)
    if not lambda_ is None:
        lambda_ = float(lambda_)
コード例 #8
0
ファイル: compute_neighbours.py プロジェクト: totonac/dissect
        elif opt in ("-o", "--output"):
            out_dir = val
        elif opt in ("-m", "--sim_measure"):
            sim_measure = val
        elif opt in ("-s", "--space"):
            spaces = val.split(",")
        elif opt in ("-n", "--no_neighbours"):
            no_neighbours = val
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    no_neighbours = int(no_neighbours)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(sim_measure, "Similarity measure required", usage)
    utils.assert_option_not_none(spaces, "Semantic space file required", usage)

    compute_neighbours(in_file, no_neighbours, out_dir, sim_measure, spaces)



if __name__ == '__main__':
    main(sys.argv)
コード例 #9
0
ファイル: train_composition.py プロジェクト: Aliases/dissect
            param = val
        elif opt == "--lambda_range":
            param_range = val.split(",")
        elif opt == "--export_params":
            export_params = val
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt in ("-h", "--help"):
            usage()
            sys.exit(0)
        else:
            usage(1)

    log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file, "Input file required", usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(model, "Model to be trained required", usage)
    utils.assert_option_not_none(arg_space, "Argument space(s) file(s) required", usage)
    utils.assert_option_not_none(phrase_space, "Phrase space file required", usage)

    crossvalidation = eval(crossvalidation)
    intercept = eval(intercept)
    utils.assert_bool(intercept, "intercept must be True/False", usage)
    utils.assert_bool(crossvalidation, "crossvalidation must be True/False", usage)

    export_params = eval(export_params)
    utils.assert_bool(export_params, "export_params must be True/False", usage)
    if not param is None:
        param = float(param)
    if not param_range is None:
コード例 #10
0
ファイル: build_core_space.py プロジェクト: totonac/dissect
            normalizations = val.split(",")
        elif opt in ("-l", "--log"):
            log_file = val
        elif opt == "--input_format":
            in_format = val
        elif opt == "--output_format":
            out_format = val
        elif opt in ("-h", "--help"):
            usage(0)
        else:
            usage(1)

    if not log_file is None:
        log_utils.config_logging(log_file)

    utils.assert_option_not_none(in_file_prefix, "Input file prefix required",
                                 usage)
    utils.assert_option_not_none(out_dir, "Output directory required", usage)
    utils.assert_option_not_none(in_format, "Input format required", usage)

    gz = eval(gz)

    utils.assert_bool(gz, "--gz value must be True/False", usage)

    build_spaces(in_file_prefix, in_format, out_dir, out_format, weightings,
                 selections, reductions, normalizations, gz)


if __name__ == '__main__':
    main(sys.argv)