Spaces:
Sleeping
Sleeping
File size: 883 Bytes
db4fba6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import json
def analyze_drs(tracking_json):
try:
data = json.loads(tracking_json)
pitch = data.get("pitching", "").lower()
impact = data.get("impact", "").lower()
traj = data.get("trajectory", "").lower()
if pitch == "outside leg":
return {"drs_decision": "NOT OUT", "reason": "Pitched outside leg - automatic NOT OUT"}
if impact == "outside off" and data.get("shot", "yes").lower() == "yes":
return {"drs_decision": "NOT OUT", "reason": "Impact outside off with shot"}
if traj == "missing":
return {"drs_decision": "NOT OUT", "reason": "Ball missing stumps"}
return {"drs_decision": "OUT", "reason": "Ball pitched in line, impact in line, and hitting stumps"}
except Exception as e:
return {"drs_decision": "NOT OUT", "reason": f"Error in tracking data: {e}"}
|