Partial Ratio

Fuzzy Wuzzy Partial Ratio Similarity Measure

class py_stringmatching.similarity_measure.partial_ratio.PartialRatio[source]

Computes the Fuzzy Wuzzy partial ratio similarity between two strings.

Fuzzy Wuzzy partial ratio raw score is a measure of the strings similarity as an int in the range [0, 100]. Given two strings X and Y, let the shorter string (X) be of length m. It finds the fuzzy wuzzy ratio similarity measure between the shorter string and every substring of length m of the longer string, and returns the maximum of those similarity measures. Fuzzy Wuzzy partial ratio sim score is a float in the range [0, 1] and is obtained by dividing the raw score by 100.

Note: In the case where either of strings X or Y are empty, we define the Fuzzy Wuzzy ratio similarity score to be 0.

get_raw_score(string1, string2)[source]

Computes the Fuzzy Wuzzy partial ratio measure raw score between two strings. This score is in the range [0,100].

Parameters:string1,string2 (str) – Input strings
Returns:Partial Ratio measure raw score (int) is returned
Raises:TypeError – If the inputs are not strings

Examples

>>> s = PartialRatio()
>>> s.get_raw_score('Robert Rupert', 'Rupert')
100
>>> s.get_raw_score('Sue', 'sue')
67
>>> s.get_raw_score('example', 'samples')
86

References

get_sim_score(string1, string2)[source]

Computes the Fuzzy Wuzzy partial ratio similarity score between two strings. This score is in the range [0,1].

Parameters:string1,string2 (str) – Input strings
Returns:Partial Ratio measure similarity score (float) is returned
Raises:TypeError – If the inputs are not strings

Examples

>>> s = PartialRatio()
>>> s.get_sim_score('Robert Rupert', 'Rupert')
1.0
>>> s.get_sim_score('Sue', 'sue')
0.67
>>> s.get_sim_score('example', 'samples')
0.86

References