API Reference
stickler
stickler: Structured object comparison and evaluation library.
This library provides tools for comparing complex structured objects with configurable comparison strategies and detailed evaluation metrics.
Model Classes
For documentation on StructuredModel, ComparableField, NonMatchField, and NonMatchType, see the Models page.
stickler.structured_object_evaluator.utils.anls_score.compare_structured_models(gt, pred)
Compare a ground truth model with a prediction.
This function wraps the compare_with method of StructuredModel for a more explicit API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gt
|
StructuredModel
|
Ground truth model |
required |
pred
|
StructuredModel
|
Prediction model |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Comparison result dictionary |
Source code in stickler/structured_object_evaluator/utils/anls_score.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
stickler.structured_object_evaluator.utils.anls_score.anls_score(gt, pred, return_gt=False, return_key_scores=False)
Calculate ANLS* score between two objects.
This function provides a simple API for getting an ANLS* score between any two objects, similar to the original anls_score function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gt
|
Any
|
Ground truth object |
required |
pred
|
Any
|
Prediction object |
required |
return_gt
|
bool
|
Whether to return the closest ground truth |
False
|
return_key_scores
|
bool
|
Whether to return detailed key scores |
False
|
Returns:
| Type | Description |
|---|---|
Union[float, Tuple[float, Any], Tuple[float, Any, Dict[str, Any]]]
|
Either just the overall score (float), or a tuple with the score and |
Union[float, Tuple[float, Any], Tuple[float, Any, Dict[str, Any]]]
|
closest ground truth, or a tuple with the score, closest ground truth, |
Union[float, Tuple[float, Any], Tuple[float, Any, Dict[str, Any]]]
|
and key scores. |
Source code in stickler/structured_object_evaluator/utils/anls_score.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
stickler.structured_object_evaluator.utils.compare_json.compare_json(gt_json, pred_json, model_cls)
Compare JSON objects using a StructuredModel.
This function is a utility for comparing raw JSON objects using a StructuredModel class. It handles missing fields and extra fields gracefully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gt_json
|
Dict[str, Any]
|
Ground truth JSON |
required |
pred_json
|
Dict[str, Any]
|
Prediction JSON |
required |
model_cls
|
Type[StructuredModel]
|
StructuredModel class to use for comparison |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with comparison results |
Source code in stickler/structured_object_evaluator/utils/compare_json.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |