langtest.metrics.string_distance.StringDistance#

class StringDistance#

Bases: object

A class for calculating various string distance metrics.

__init__()#

Methods

__init__()

available_string_distance([distance])

Get the specified distance metric for string similarity calculations.

validate_input()

A decorator function for validating input strings.

classmethod available_string_distance(distance: str = 'jaro')#

Get the specified distance metric for string similarity calculations.

Parameters:

distance (str, optional) – The desired distance metric. Defaults to “jaro”.

Returns:

The corresponding distance calculation method.

Return type:

callable

Raises:

ValueError – If the specified distance metric is not supported.

validate_input()#

A decorator function for validating input strings.

Parameters:

func – The function to be decorated.

Returns:

The decorated function.