Spaces:
Sleeping
Sleeping
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}"} | |