File size: 2,166 Bytes
a984ba9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import argparse
import json

import pandas as pd

from project_settings import environment, project_path


def get_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--filename",
        default="evaluation_results_max7.xlsx",
        type=str
    )
    parser.add_argument(
        "--dataset",
        default=(project_path / "data/dataset/agent-lingoace-zh-400-choice.jsonl").as_posix(),
        type=str
    )
    args = parser.parse_args()
    return args


def main():
    args = get_args()

    dataset = dict()
    with open(args.dataset, "r", encoding="utf-8") as f:
        for row in f:
            row = json.loads(row)
            idx = row["idx"]
            prompt = row["prompt"]
            response = row["response"]
            dataset[idx] = row

    result = list()
    df = pd.read_excel(args.filename)
    for i, row in df.iterrows():
        # print(row)
        idx = row["idx"]
        conversation = row["conversation"]
        expected = row["expected"]
        actual_label = row["actual_label"]
        actual_reason = row["actual_reason"]
        correct = row["correct"]
        note = row["note"]

        if correct is False:
            print(idx)
            print(conversation)
            print(expected, actual_label)
            print(actual_reason)
            print(note)
            print("+" * 150)

            dataset_ = dataset[idx]
            prompt = dataset_["prompt"]
            response = dataset_["response"]
            print(prompt)
            print(response)
            print("-" * 150)

            result.append({
                "idx": idx,
                "conversation": conversation,
                "expected": expected,
                "actual_label": actual_label,
                "actual_reason": actual_reason,
                "note": note,
                "prompt": prompt,
                "response": response,
                "op": None,
                "remark": None,

            })
    result = pd.DataFrame(result)
    result.to_excel("result.xlsx", index=False)
    return


if __name__ == "__main__":
    main()