From ddcafac30fca5a0b125b1be1c4f50eb73004506a Mon Sep 17 00:00:00 2001 From: David Chang Date: Thu, 7 Mar 2024 23:16:55 +0800 Subject: [PATCH 1/3] ver Mar7thv2 updated requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 497b9f8..e4ab463 100644 --- a/requirements.txt +++ b/requirements.txt @@ -44,3 +44,4 @@ dashscope google-generativeai PyYaml mutagen +pytesseract From b8d54e8bac6d3f84ff94d27e06a7f088becf4120 Mon Sep 17 00:00:00 2001 From: Timothyxxx <384084775@qq.com> Date: Fri, 8 Mar 2024 11:47:14 +0800 Subject: [PATCH 2/3] Fix a bug in Chrome evaluator --- desktop_env/evaluators/getters/chrome.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop_env/evaluators/getters/chrome.py b/desktop_env/evaluators/getters/chrome.py index 8bd5842..2a6a9ea 100644 --- a/desktop_env/evaluators/getters/chrome.py +++ b/desktop_env/evaluators/getters/chrome.py @@ -589,6 +589,10 @@ def get_active_url_from_accessTree(env, config): if len(elements) == 0: print("no elements found") return None + elif elements[-1].text is None: + print("no text found") + return None + active_tab_url = config["goto_prefix"] + elements[0].text if "goto_prefix" in config.keys() else "https://" + \ elements[0].text print("active tab url now: {}".format(active_tab_url)) From ce23f3dab484c19f4aac6b3f020435262d55d64f Mon Sep 17 00:00:00 2001 From: David Chang Date: Fri, 8 Mar 2024 13:28:34 +0800 Subject: [PATCH 3/3] ver Mar8th fixed a task and a metric --- desktop_env/evaluators/metrics/table.py | 6 +-- desktop_env/evaluators/metrics/utils.py | 7 ++- .../b5062e3e-641c-4e3a-907b-ac864d2e7652.json | 45 ++++++++++--------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/desktop_env/evaluators/metrics/table.py b/desktop_env/evaluators/metrics/table.py index 4a58e50..0a03295 100644 --- a/desktop_env/evaluators/metrics/table.py +++ b/desktop_env/evaluators/metrics/table.py @@ -194,7 +194,7 @@ def compare_table(result: str, expected: str = None, **options) -> float: # sheet_idx1: as sheet_idx0 # rules: list of dict, each dict is like # { "range": ["A1:B6", "C2:E5"], - # "type": "includes" | "includes_by" | "fuzzy_match" | "exact_match", # 0 includes 1, 0 includes_by 1 + # "type": "includes" | "included_by" | "fuzzy_match" | "exact_match", # 0 includes 1, 0 includes_by 1 # "threshold": 85, // for fuzzy match # "ignore_case": true | false, # "ignore_chars": " ()", # filtered out @@ -232,9 +232,9 @@ def compare_table(result: str, expected: str = None, **options) -> float: value2 = value2.lower() if rl["type"]=="includes": - metric: bool = value1 in value2 - elif rl["type"]=="includes_by": metric: bool = value2 in value1 + elif rl["type"]=="included_by": + metric: bool = value1 in value2 elif rl["type"]=="fuzzy_match": metric: bool = fuzz.ratio(value1, value2) >= rl.get("threshold", 85.) elif rl["type"]=="exact_match": diff --git a/desktop_env/evaluators/metrics/utils.py b/desktop_env/evaluators/metrics/utils.py index b57de00..d1530b9 100644 --- a/desktop_env/evaluators/metrics/utils.py +++ b/desktop_env/evaluators/metrics/utils.py @@ -274,7 +274,8 @@ def load_pivot_tables(xlsx_file: Workbook, sheet_name: str, **options) -> Dict[s # }}} function load_pivot_tables # -_shared_str_selector = lxml.cssselect.CSSSelector("oo|sst>oo|si>oo|t", namespaces=_xlsx_ns_mapping) +_shared_str_selector = lxml.cssselect.CSSSelector("oo|sst>oo|si", namespaces=_xlsx_ns_mapping) +_shared_str_value_selector = lxml.cssselect.CSSSelector("oo|t", namespaces=_xlsx_ns_mapping) def read_cell_value(xlsx_file: str, sheet_name: str, coordinate: str) -> Any: @@ -285,7 +286,9 @@ def read_cell_value(xlsx_file: str, sheet_name: str, coordinate: str) -> Any: with z_f.open("xl/sharedStrings.xml") as f: shared_str_xml: _Element = lxml.etree.fromstring(f.read()) str_elements: List[_Element] = _shared_str_selector(shared_str_xml) - shared_strs: List[str] = [elm.text for elm in str_elements] + shared_strs: List[str] = [ "".join(t.text for t in _shared_str_value_selector(elm))\ + for elm in str_elements + ] except: logger.debug("Read shared strings error: %s", xlsx_file) diff --git a/evaluation_examples/examples/multi_apps/b5062e3e-641c-4e3a-907b-ac864d2e7652.json b/evaluation_examples/examples/multi_apps/b5062e3e-641c-4e3a-907b-ac864d2e7652.json index 5d84224..e9b0278 100644 --- a/evaluation_examples/examples/multi_apps/b5062e3e-641c-4e3a-907b-ac864d2e7652.json +++ b/evaluation_examples/examples/multi_apps/b5062e3e-641c-4e3a-907b-ac864d2e7652.json @@ -64,35 +64,40 @@ "func": "compare_table", "result": { "type": "vm_file", - "path": [ - "/home/user/authors.xlsx", - "/home/user/authors-Sheet1.csv" - ], - "dest": [ - "authors.xlsx", - "authors-Sheet1.csv" - ], - "multi": true + "path": "/home/user/authors.xlsx", + "dest": "authors.xlsx" }, "expected": { "type": "cloud_file", - "path": [ - "https://drive.google.com/uc?id=1fttbvfHuoQfsQUk3fVXkJsCu231jhnQj&export=download", - "https://drive.google.com/uc?id=1fq4hbk1g9R_SjknzwFAqvyF1ICyNYfok&export=download" - ], - "dest": [ - "authors-gt.xlsx", - "authors-gt-Sheet1.csv" - ], - "multi": true + "path": "https://drive.google.com/uc?id=1fttbvfHuoQfsQUk3fVXkJsCu231jhnQj&export=download", + "dest": "authors-gt.xlsx" }, "options": { "rules": [ { - "type": "sheet_print", + "type": "sheet_fuzzy", "sheet_idx0": "RNSheet1", "sheet_idx1": "ENSheet1", - "ignore_case": true + "rules": [ + { + "range": ["A1:C1"], + "type": "includes", + "ignore_case": true + }, + { + "range": ["A2:B5"], + "type": "exact_match", + "trim_leadings": " ", + "trim_trailings": " " + }, + { + "range": ["C2:C5"], + "type": "exact_match", + "trim_leadings": " ", + "trim_trailings": " ", + "ignore_case": true + } + ] } ] }