Upload json_semval/types.py with huggingface_hub
Browse files- json_semval/types.py +41 -0
json_semval/types.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import Any, List, Optional, TypedDict
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Prediction(TypedDict, total=False):
|
| 7 |
+
error_type: str
|
| 8 |
+
jsonpath: str
|
| 9 |
+
fix_action: str
|
| 10 |
+
fix_value: Optional[str]
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class Report(TypedDict):
|
| 14 |
+
valid: bool
|
| 15 |
+
rule_errors: List[dict]
|
| 16 |
+
ml_predictions: List[Prediction]
|
| 17 |
+
applied_fixes: List[Prediction]
|
| 18 |
+
corrected_json: Any
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# Common constants
|
| 22 |
+
ERROR_TYPES = [
|
| 23 |
+
"wrong_type",
|
| 24 |
+
"alias_key",
|
| 25 |
+
"invalid_date",
|
| 26 |
+
"enum_near_miss",
|
| 27 |
+
"cross_field",
|
| 28 |
+
"boolean_text",
|
| 29 |
+
"number_text",
|
| 30 |
+
"extra_key",
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
FIX_ACTIONS = [
|
| 34 |
+
"rename_key",
|
| 35 |
+
"cast_number",
|
| 36 |
+
"cast_bool",
|
| 37 |
+
"parse_date_iso",
|
| 38 |
+
"map_enum",
|
| 39 |
+
"swap_dates",
|
| 40 |
+
"fill_default",
|
| 41 |
+
]
|