23 lines
738 B
Python
23 lines
738 B
Python
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)
|