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