From 1ff9f5c38b3663739733e21dbf6f5b1baa7d7da4 Mon Sep 17 00:00:00 2001 From: David Chang Date: Mon, 26 Feb 2024 20:50:08 +0800 Subject: [PATCH] ver Feb26th statistics of action types of exp_som branch --- action_type_analysis.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 action_type_analysis.py diff --git a/action_type_analysis.py b/action_type_analysis.py new file mode 100644 index 0000000..750ef9b --- /dev/null +++ b/action_type_analysis.py @@ -0,0 +1,22 @@ +import json +import glob + +from typing import Dict, Counter +from typing import Any + +import collections + +action_counter: Counter[str] = collections.Counter() +for trjctr in glob.glob("snapshots/exp_som/exp_trajectory/**/*.json", recursive=True): + with open(trjctr) as f: + for l in f: + step: Dict[str, Any] = json.loads(l) + #print(step) + for rsp in step.get("action", "").splitlines(): + if rsp.startswith("pyautogui."): + action_counter[rsp[10:rsp.find("(")]] += 1 + elif rsp in {"WAIT", "FAIL", "DONE"}: + action_counter[rsp] += 1 + +for k, nb in sorted(action_counter.items(), key=(lambda itm: itm[1]), reverse=True): + print(k, nb)