diff --git a/desktop_env/envs/desktop_env.py b/desktop_env/envs/desktop_env.py index ec00181..7aaf84e 100644 --- a/desktop_env/envs/desktop_env.py +++ b/desktop_env/envs/desktop_env.py @@ -79,6 +79,7 @@ class DesktopEnv(gym.Env): self.metric: Metric = getattr(metrics, self.evaluator["func"]) self.result_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["result"]["type"])) self.expected_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["expected"]["type"])) + self.metric_options: Dict[str, Any] = self.evaluator.get("options", {}) # Initialize emulator and controller print("Initializing...") @@ -165,6 +166,7 @@ class DesktopEnv(gym.Env): self.metric: Metric = getattr(metrics, self.evaluator["func"]) self.result_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["result"]["type"])) self.expected_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["expected"]["type"])) + self.metric_options = self.evaluator.get("options", {}) self.setup_controller.reset_cache_dir(self.cache_dir) @@ -237,7 +239,7 @@ class DesktopEnv(gym.Env): result = self.result_getter(self, self.evaluator["result"]) expected = self.expected_getter(self, self.evaluator["expected"]) - metric: float = self.metric(result, expected) + metric: float = self.metric(result, expected, **self.metric_options) return metric diff --git a/desktop_env/evaluators/metrics/table.py b/desktop_env/evaluators/metrics/table.py index bbb99de..b07e6e6 100644 --- a/desktop_env/evaluators/metrics/table.py +++ b/desktop_env/evaluators/metrics/table.py @@ -130,4 +130,4 @@ if __name__ == '__main__': path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx" path2 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx" - print(compare_with_charts(path1, path2, chart_props=["title"])) + print(compare_with_charts(path1, path2, chart_props=["type"])) diff --git a/desktop_env/evaluators/metrics/utils.py b/desktop_env/evaluators/metrics/utils.py index ff4317e..a466834 100644 --- a/desktop_env/evaluators/metrics/utils.py +++ b/desktop_env/evaluators/metrics/utils.py @@ -48,6 +48,13 @@ def load_sparklines(xlsx_file: str) -> Dict[str, str]: sparklines_dict[sparkline["x14:sparkline"]["xm:sqref"]] = sparkline["x14:sparkline"]["xm:f"] return sparklines_dict +# Available Chart Properties: +# title: str +# anchor: ["oneCell" | "twoCell" | "absolute", col0, row0, col1, row1] +# width: number +# height: number +# type: "scatterChart" | "lineChart" | "barChart" +# xtitle, ytitle, ztitle: str def load_charts(xlsx_file: str, **options) -> Dict[str, Any]: """ Args: @@ -100,6 +107,15 @@ def load_charts(xlsx_file: str, **options) -> Dict[str, Any]: info["width"] = ch.width if "height" in chart_props: info["height"] = ch.height + if "type" in chart_props: + info["type"] = ch.tagname + + if "xtitle" in chart_props: + info["xtitle"] = ch.x_axis.title.tx.rich.p[0].r[0].t + if "ytitle" in chart_props: + info["ytitle"] = ch.y_axis.title.tx.rich.p[0].r[0].t + if "ztitle" in chart_props: + info["ztitle"] = ch.z_axis.title.tx.rich.p[0].r[0].t chart_set[series] = info return chart_set @@ -139,4 +155,4 @@ if __name__ == "__main__": #df1 = pd.read_excel(path1) #print(df1) - print(load_charts(path1, chart_props=["title", "width", "height"])) + print(load_charts(path1, chart_props=["title", "xtitle", "ytitle", "type"])) diff --git a/evaluation_examples/examples/libreoffice_calc/347ef137-7eeb-4c80-a3bb-0951f26a8aff.json b/evaluation_examples/examples/libreoffice_calc/347ef137-7eeb-4c80-a3bb-0951f26a8aff.json index 20258e0..548cd29 100644 --- a/evaluation_examples/examples/libreoffice_calc/347ef137-7eeb-4c80-a3bb-0951f26a8aff.json +++ b/evaluation_examples/examples/libreoffice_calc/347ef137-7eeb-4c80-a3bb-0951f26a8aff.json @@ -37,6 +37,11 @@ "type": "cloud_file", "path": "https://101.43.24.67/s/SLL4CgyMiyre3Ss/download/Create_column_charts_using_statistics_gold.xlsx", "dest": "Create_column_charts_using_statistics_gold.xlsx" + }, + "options": { + "chart_props": [ + "type" + ] } } }