Beispiel #1
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    global_is_equal_flag = True
    global_msg = ""
    for test_name in in_data:
        hypothesis = handler(in_data[test_name], RANDOM_SEED)
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(
            out_data[test_name],
            hypothesis,
            ignored_keys=["id", "used_phrases"])
        if msg and len(msg.split("`")) == 5:
            _, ground_truth_text, _, hypothesis_text, _ = msg.split("`")
            is_equal_flag, ratio = test_utils.compare_text(
                ground_truth_text, hypothesis_text, 0.80)
            if not is_equal_flag:
                msg = f"{msg} ratio = {ratio}"
        # assert is_equal_flag, msg
        if is_equal_flag:
            print("Success")
        else:
            print(is_equal_flag, msg)
            global_msg += f"\nFailed test_name: {test_name} <-> msg: {msg}"
            global_is_equal_flag = False
    assert global_is_equal_flag, global_msg
Beispiel #2
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    for test_name in in_data:
        hypothesis = handler(in_data[test_name])
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(
            out_data[test_name], hypothesis)
        assert is_equal_flag, msg
        print("Success")
Beispiel #3
0
def run_test(handler) -> None:
    in_data, out_data = test_utils.get_dataset()
    for test_name in in_data:
        print(f"test name: {test_name}")
        cur_in_test = in_data[test_name]
        cur_out_test = out_data[test_name]
        for cur_in_data, cur_out_data in zip(cur_in_test, cur_out_test):
            cur_real_out_data = handler(cur_in_data, RANDOM_SEED)
            cur_real_out_data = cur_real_out_data[0]["facts"]

            assert cur_real_out_data == cur_out_data, f"expect out: {cur_out_data}\n real out: {cur_real_out_data}"

    print("Success")
Beispiel #4
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    for test_name in in_data:
        hypothesis = handler(in_data[test_name], RANDOM_SEED)
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(out_data[test_name], hypothesis, ignored_keys=["id"])
        if msg and len(msg.split("`")) == 5:
            _, ground_truth_text, _, hypothesis_text, _ = msg.split("`")
            is_equal_flag, ratio = test_utils.compare_text(ground_truth_text, hypothesis_text, 0.80)
            if not is_equal_flag:
                msg = f"{msg} ratio = {ratio}"
        assert is_equal_flag, msg
        print("Success")