예제 #1
0
파일: app.py 프로젝트: umanlp/debie-backend
def debiasing_gbdd_bam():
    logging.info("APP: " + str(datetime.datetime.now()) + " GBDDxBAM Debiasing started")
    content = request.get_json()
    bar = request.args.to_dict()
    response, status_code = debiasing_controller.debiasing('gbddxbam', content, bar)

    return response, status_code
예제 #2
0
파일: app.py 프로젝트: umanlp/debie-backend
def debiasing_bam_gbdd():
    logging.info("APP: " + str(datetime.datetime.now()) + " BAMxGBDD Debiasing started")
    content = request.get_json()
    bar = request.args.to_dict()
    # print(content)
    # print(bar)
    response, status_code = debiasing_controller.debiasing('bamxgbdd', content, bar)

    return response, status_code
예제 #3
0
def debiasing_config(configfile):
    global space
    global uploaded
    global json_value
    global lower
    global debiasing
    global specification_data
    global specification_file

    with open(configfile) as json_file:
        config_data = json.load(json_file)

    if 'space' in config_data:
        space = config_data['space']
    else:
        space = 'fasttext'
    if 'uploaded' in config_data:
        uploaded = config_data['uploaded']
    else:
        uploaded = "false"
    if 'json' in config_data:
        json_value = config_data['json']
    if 'lower' in config_data:
        lower = config_data['lower']
    if 'debiasing' in config_data:
        debiasing = config_data['debiasing']
    else:
        debiasing = 'bam'
    if 'pca' in config_data:
        pca = config_data['pca']
    specification_data = config_data
    specification_file = configfile

    print("\nDEBIE -- " + debiasing + "-Debiasing started at " +
          str(datetime.now()))
    bar = {"space": space, "lower": lower, "pca": pca, "uploaded": uploaded}
    response, status_code = debiasing_controller.debiasing(
        debiasing, specification_data, bar)
    filename = specification_file.replace(".json", "").replace(
        ".txt", "") + "-debiased" + ".json"
    file = open(filename, "w")
    file.write(response)
    print("\n\033[96m" + "DEBIE -- Debiased Space saved as " + filename +
          "\033[0m")
    print("    Time: " + str(datetime.now()) + "\n")

    return file
예제 #4
0
def save_full_space():
    global space
    global uploaded
    global specification_data
    global specification_file
    global lower
    global debiasing
    global pca

    print("\nDEBIE -- " + debiasing + "-Debiasing started at " +
          str(datetime.now()))
    bar = {"space": space, "lower": lower, "pca": pca, "uploaded": uploaded}
    vocab, vecs = debiasing_controller.debiasing(debiasing, specification_data,
                                                 bar)
    vocab_filename = specification_file.replace(".json", "-debiased.vocab")
    vecs_filename = specification_file.replace(".json", "-debiased.vecs")
    numpy.save(vocab_filename, vocab, allow_pickle=True)
    numpy.save(vecs_filename, vecs, allow_pickle=True)
    print("\n\033[96m" + "DEBIE -- Debiased Space saved as " + vocab_filename +
          " and  " + vecs_filename + "\033[0m")
    print("    Time: " + str(datetime.now()) + "\n")
예제 #5
0
def exe_debiasing():
    global space
    global uploaded
    global specification_data
    global specification_file
    global lower
    global debiasing
    global pca

    print("\nDEBIE -- " + debiasing + "-Debiasing started at " +
          str(datetime.now()))
    bar = {"space": space, "lower": lower, "pca": pca, "uploaded": uploaded}
    response, status_code = debiasing_controller.debiasing(
        debiasing, specification_data, bar)
    filename = specification_file.replace(".json", "").replace(
        ".txt", "") + "-debiased" + ".json"
    file = open(filename, "w")
    file.write(response)
    print("\n\033[96m" + "DEBIE -- Debiased Space saved as " + filename +
          "\033[0m")
    print("    Time: " + str(datetime.now()) + "\n")

    return select_method()