File size: 4,170 Bytes
a2609f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
answer_key.py —— "标准答案对照表" + "题目自动分类器"(仅供我们自己调试看结果用)

1. REFERENCE_ANSWERS:一张"标准答案表"。GAIA 这 20 道题的官方正确答案是公开的(来自数据集里
    的 metadata.jsonl 文件),我们把它抄在这里。
    注意:这张表【不参与答题】!agent 答题时根本不会看它。它唯一的用途是:在结果表格里,把
    "正确答案"和"我们 agent 提交的答案"并排显示出来,方便我们一眼看出哪几道答错了。
    (因为评分服务器只告诉我们总分,不会告诉我们具体哪题对哪题错。)

2. classify_question:根据题目内容/附件类型,自动给每道题贴一个"类型标签"(比如"看图题""音频题"
    "网页检索题"),同样是为了让结果表格更直观。
"""

import re

# 一个"字典"(dict):左边是每道题的唯一编号 task_id,右边是这道题的官方标准答案。
REFERENCE_ANSWERS = {
    "8e867cd7-cff9-4e6c-867a-ff5ddc2550be": "3",
    "a1e91b78-d3d8-4675-bb8d-62741b4b68a6": "3",
    "2d83110e-a098-4ebb-9987-066c06fa42d0": "Right",
    "cca530fc-4052-43b2-b130-b30968d8aa44": "Rd5",
    "4fc2f1ae-8625-45b5-ab34-ad4433bc21f8": "FunkMonk",
    "6f37996b-2ac7-44b0-8e68-6d28256631b4": "b, e",
    "9d191bce-651d-4746-be2d-7ef8ecadb9c2": "Extremely",
    "cabe07ed-9eca-40ea-8ead-410ef5e83f91": "Louvrier",
    "3cef3a44-215e-4aed-8e3b-b1e3f08063b7": "broccoli, celery, fresh basil, lettuce, sweet potatoes",
    "99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3": "cornstarch, freshly squeezed lemon juice, granulated sugar, pure vanilla extract, ripe strawberries",
    "305ac316-eef6-4446-960a-92d80d542f82": "Wojciech",
    "f918266a-b3e0-4914-865d-4faa564f1aef": "0",
    "3f57289b-8c60-48be-bd80-01f8099ca449": "519",
    "1f975693-876d-457b-a649-393859e79bf3": "132, 133, 134, 197, 245",
    "840bfca7-4f7b-481a-8794-c560c340185d": "80GSFC21M0002",
    "bda648d7-d618-4883-88f4-3466eabd860e": "Saint Petersburg",
    "cf106601-ab4f-4af9-b045-5295fe67b37d": "CUB",
    "a0c07678-e491-4bbc-8f0b-07405144218f": "Yoshida, Uehara",
    "7bd855d8-463d-4ed5-93ca-5fe35145f733": "89706.00",
    "5a0c1adf-205e-4841-a666-7c3ef95def9d": "Claus",
}


def classify_question(question: str, file_name: str = "") -> str:
    """根据题目和附件名,猜测这道题属于哪种类型,返回一个标签字符串。"""
    # 先看有没有附件、附件是什么后缀名(.xlsx/.mp3/.png...),据此判断题型。
    # .lower() 把文件名转成小写,避免大小写不一致导致判断失败(.MP3 和 .mp3 应视为同一种)。
    fn = (file_name or "").lower()
    if fn.endswith((".xlsx", ".xls", ".csv", ".tsv")):   # 表格类附件
        return "file: spreadsheet"
    if fn.endswith((".mp3", ".wav", ".m4a", ".flac", ".ogg")):  # 音频类附件
        return "file: audio"
    if fn.endswith((".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp")):  # 图片类附件
        return "file: image"
    if fn.endswith((".py", ".txt", ".json", ".c", ".cpp", ".java", ".js")):  # 代码/纯文本类附件
        return "file: code/text"
    if fn.endswith((".pdf", ".docx")):   # 文档类附件
        return "file: document"
    if fn:   # 有附件但后缀不在上面列举的范围内
        return "file: other"

    # 没有附件时,转而分析题目文字本身。
    q = question.lower()
    if "youtube.com" in q or "youtu.be" in q:   # 题目里出现 YouTube 链接 → 视频题
        return "video (YouTube)"
    # 有的题目把整句话倒着写(比如把 "the" 写成 "eht"),用正则查这种倒写的标志词 → 文字处理题。
    if re.search(r"\beht\b", question) or re.search(r"\brewsna\b", q):
        return "text manipulation"
    # 出现表格符号 "|*|" 或"交换律 commutative"等字样 → 逻辑/表格运算题。
    if "|*|" in question or ("commutative" in q) or ("set s" in q):
        return "logic/table"
    if "wikipedia" in q:   # 明确提到维基百科
        return "web: wikipedia"
    return "web research"   # 以上都不是 → 默认归为"上网检索题"