An evaluator that calculates the edit distance between JSON strings.
This evaluator computes a normalized Damerau-Levenshtein distance between two JSON strings after parsing them and converting them to a canonical format (i.e., whitespace and key order are normalized). It can be customized with alternative distance and canonicalization functions.
JsonEditDistanceEvaluator(
self,
string_distance: Callable[[str, str], float] | None = None,
canonicalize: Callable[[Any], Any] | None = None,
**_: Any = {}
)| Name | Type | Description |
|---|---|---|
string_distance | Callable[[str, str], float] | None | Default: NoneA callable that computes the distance between two strings.
If not provided, a Damerau-Levenshtein distance from the |
canonicalize | Callable[[Any], Any] | None | Default: NoneA callable that converts a parsed JSON object into its canonical string form. If not provided, the default behavior is to serialize the JSON with sorted keys and no extra whitespace. |