From 9fe3a5db3b3a1e7430173dc1029b0b4348e88da8 Mon Sep 17 00:00:00 2001 From: tsuky_chen <3107760494@qq.com> Date: Tue, 16 Jan 2024 01:07:40 +0800 Subject: [PATCH] update libreoffice impress eval --- desktop_env/evaluators/metrics/__init__.py | 2 +- desktop_env/evaluators/metrics/impress.py | 23 ++++++++++ .../39478d4a-1049-456f-aa77-407811393add.json | 37 +++++++++++++++ .../9ec204e4-f0a3-42f8-8458-b772a6797cab.json | 40 ++++++++++++++-- .../af23762e-2bfd-4a1d-aada-20fa8de9ce07.json | 40 ++++++++++++++-- .../c59742c0-4323-4b9d-8a02-723c251deaa0.json | 46 +++++++++++++++++-- 6 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 evaluation_examples/examples/libreoffice_impress/39478d4a-1049-456f-aa77-407811393add.json diff --git a/desktop_env/evaluators/metrics/__init__.py b/desktop_env/evaluators/metrics/__init__.py index 200b56f..59ebab2 100644 --- a/desktop_env/evaluators/metrics/__init__.py +++ b/desktop_env/evaluators/metrics/__init__.py @@ -14,4 +14,4 @@ from .gimp import increase_saturation, decrease_brightness, check_file_exists, c from .general import check_csv, check_accessibility_tree, check_list, run_sqlite3, check_json from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed -from .impress import check_slide_numbers_color, compare_pptx_files, check_for_two_lines +from .impress import check_slide_numbers_color, compare_pptx_files, check_for_two_lines, check_for_audio, check_formula_shape, check_file_exists diff --git a/desktop_env/evaluators/metrics/impress.py b/desktop_env/evaluators/metrics/impress.py index 7268aef..719ae56 100644 --- a/desktop_env/evaluators/metrics/impress.py +++ b/desktop_env/evaluators/metrics/impress.py @@ -71,6 +71,29 @@ def check_file_exists(directory, filename): file_path = os.path.join(directory, filename) return 1 if os.path.isfile(file_path) else 0 +def has_audio_on_page(slide): + for shape in slide.shapes: + if shape.shape_type == 13: + return True + return False + +def check_for_audio(prs): + prs = Presentation(prs) + for i, slide in enumerate(prs.slides): + if has_audio_on_page(slide): + return 1 + return 0 + +def check_formula_shape(prs): + prs = Presentation(prs) + slide = prs.slides[13] + + for shape in slide.shapes: + + if shape.has_text_frame and shape.shape_type == 1: + return 1 + return 0 + if __name__ == "__main__": path1 = "../../任务数据/LibreOffice Impress/Change_Color_Slide_Number_gold_textbox.pptx" presentation = Presentation(path1) diff --git a/evaluation_examples/examples/libreoffice_impress/39478d4a-1049-456f-aa77-407811393add.json b/evaluation_examples/examples/libreoffice_impress/39478d4a-1049-456f-aa77-407811393add.json new file mode 100644 index 0000000..e5ee5d6 --- /dev/null +++ b/evaluation_examples/examples/libreoffice_impress/39478d4a-1049-456f-aa77-407811393add.json @@ -0,0 +1,37 @@ +{ + "id": "39478d4a-1049-456f-aa77-407811393add", + "snapshot": "libreoffice_impress", + "instruction": "Could you help me add a hat symbol to \"Y\" in text in page 14? I need to represent vector sign for my statistics class.", + "source": "https://www.reddit.com/r/libreoffice/comments/jul3o8/putting_cap_or_hat_or_carat_symbol_in_libre/", + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1WT1-L0iiIlF2kuIK77IDxTfBaQ0X0BbX&export=download&authuser=0&confirm=t&uuid=0b69767e-1f3e-49ce-88a7-1036ef25bcaf&at=APZUnTXZ_sqEZUrHNx1edWep017b:1705337750065", + "path": "Desktop/Ch5.pptx" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/Ch5.pptx" + } + } + ], + "trajectory": "trajectories/", + "related_apps": [ + "libreoffice_impress" + ], + "evaluator": { + "func": "check_formula_shape", + "result": { + "type": "vm_file", + "path": "Desktop/Ch5.pptx", + "dest": "Ch5.pptx" + } + } +} \ No newline at end of file diff --git a/evaluation_examples/examples/libreoffice_impress/9ec204e4-f0a3-42f8-8458-b772a6797cab.json b/evaluation_examples/examples/libreoffice_impress/9ec204e4-f0a3-42f8-8458-b772a6797cab.json index 8d8255e..c825ce7 100644 --- a/evaluation_examples/examples/libreoffice_impress/9ec204e4-f0a3-42f8-8458-b772a6797cab.json +++ b/evaluation_examples/examples/libreoffice_impress/9ec204e4-f0a3-42f8-8458-b772a6797cab.json @@ -1,12 +1,42 @@ { "id": "9ec204e4-f0a3-42f8-8458-b772a6797cab", "snapshot": "libreoffice_impress", - "instruction": "Could you help me copy and paste the first 3 slides?", + "instruction": "Make a duplicate of the last two slides for me, please.", "source": "https://www.tiktok.com/@lil.d1rt_/video/7247574148887629083", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1ad5vUXasdN2MypNap-pBUmgPg5FaxmDA&export=download&authuser=0&confirm=t&uuid=9dc069bb-edd3-4ae9-b356-4c6543778584&at=APZUnTXbgLHjv1MhMFy1IfZL3fQI:1705338128337", + "path": "Desktop/MLA_Workshop_061X_Works_Cited.pptx" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/MLA_Workshop_061X_Works_Cited.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "compare_pptx_files", + "expected": { + "type": "cloud_file", + "path": "https://drive.usercontent.google.com/download?id=1otbzscpOZ0tCXMvsMC0MmNWUC7Pv71of&export=download&authuser=0&confirm=t&uuid=faa0b0c1-6b14-4bce-a1fd-ccf824ee1e60&at=APZUnTXw6TlBOlrPPZ2OhfGnNPf0:1705338135842", + "dest": "MLA_Workshop_061X_Works_Cited_Gold.docx" + }, + "result": { + "type": "vm_file", + "path": "Desktop/MLA_Workshop_061X_Works_Cited.pptx", + "dest": "MLA_Workshop_061X_Works_Cited.pptx" + } + } +} \ No newline at end of file diff --git a/evaluation_examples/examples/libreoffice_impress/af23762e-2bfd-4a1d-aada-20fa8de9ce07.json b/evaluation_examples/examples/libreoffice_impress/af23762e-2bfd-4a1d-aada-20fa8de9ce07.json index 93d0a94..db71d72 100644 --- a/evaluation_examples/examples/libreoffice_impress/af23762e-2bfd-4a1d-aada-20fa8de9ce07.json +++ b/evaluation_examples/examples/libreoffice_impress/af23762e-2bfd-4a1d-aada-20fa8de9ce07.json @@ -1,12 +1,42 @@ { "id": "af23762e-2bfd-4a1d-aada-20fa8de9ce07", "snapshot": "libreoffice_impress", - "instruction": "Please make a summary slide of the whole presentation for me", + "instruction": "I am making PPT on LibreOffice Impress for presentation tomorrow. I need to summarize contents on one slide. Could you make a summary slide for me?", "source": "https://superuser.com/questions/1059080/how-to-make-a-summary-slide-in-impress-listing-the-titles-of-all-slides-autom", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1zmtomIzSgSjnYZbhgtH4n90L5mV9bS7L&export=download&authuser=0&confirm=t&uuid=1966ab03-1e17-447a-aeb4-71a753eca196&at=APZUnTVoWHV6z8LJi5VHADuQE6VG:1705319233167", + "path": "Desktop/Forests.pptx" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/Forests.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "compare_pptx_files", + "expected": { + "type": "cloud_file", + "path": "https://drive.usercontent.google.com/download?id=1nRwmFgYdskv3EiriZZFoT8TzM9CsG5B0&export=download&authuser=0&confirm=t&uuid=f2f919df-2867-4bc3-8bb9-dabd51108ebb&at=APZUnTWzw9LJWWXvH0cvdaWL-Ij-:1705319339474", + "dest": "Forests_Gold.docx" + }, + "result": { + "type": "vm_file", + "path": "Desktop/Forests.pptx", + "dest": "Forests.pptx" + } + } +} \ No newline at end of file diff --git a/evaluation_examples/examples/libreoffice_impress/c59742c0-4323-4b9d-8a02-723c251deaa0.json b/evaluation_examples/examples/libreoffice_impress/c59742c0-4323-4b9d-8a02-723c251deaa0.json index 5321e76..9eb877c 100644 --- a/evaluation_examples/examples/libreoffice_impress/c59742c0-4323-4b9d-8a02-723c251deaa0.json +++ b/evaluation_examples/examples/libreoffice_impress/c59742c0-4323-4b9d-8a02-723c251deaa0.json @@ -1,12 +1,48 @@ { "id": "c59742c0-4323-4b9d-8a02-723c251deaa0", "snapshot": "libreoffice_impress", - "instruction": "Could you help me add video into the presentation file?", + "instruction": "I am making PPT about the history of baseball. I want to add an introduction audio named \"Baseball.mp3\" on the Desktop into my PPT, but I do not know how. Could you help me add audio into my presentation file?", "source": "https://www.reddit.com/r/libreoffice/comments/17lcdrp/audio_not_supported_in_libreoffice_impress/", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1Oy5Zga6PnvpIwJ1OHMdFf3mSbm_YClHh&export=download&authuser=0&confirm=t&uuid=da1db839-da27-4bb5-a4fc-0358342f493b&at=APZUnTVsLyGsj8qI1rPyGAUTCX4F:1705324246149", + "path": "Desktop/Mady_and_Mia_Baseball.pptx" + } + ] + } + }, + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1a-DaT1LUuvh55GsjpJkhpjcDTh8CPzkl&export=download&authuser=0&confirm=t&uuid=2bfb7700-5222-47ad-9aee-e5c22b50dbfe&at=APZUnTW7RQR5HI9giEl-cirnSX3q:1705320977391", + "path": "Desktop/Baseball.mp3" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/Mady_and_Mia_Baseball.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "check_for_audio", + "result": { + "type": "vm_file", + "path": "Desktop/Mady_and_Mia_Baseball.pptx", + "dest": "Mady_and_Mia_Baseball.pptx" + } + } +} \ No newline at end of file