0

# Jaro Distance

Unsolved###### NLP

##### Problem reported in interviews at

Jaro Distance is a measure of similarity between two strings.The Jaro Similarity is calculated using the formula:

\(\begin{aligned} Sim_J (s_1, s_2) = \begin{cases} 0 &\text{if } m = 0, \\ \frac{1}{3}\left( \frac{m}{|s_1|} + \frac{m}{|s_2|} + \frac{m - t}{m} \right) &\text{otherwise}. \end{cases} \end{aligned}\)

m is the number of matching characters

t is half the number of transpositions

|s1| and |s2| is the length of string s1 and s2 respectively.

The value of Jaro Distance should always be between 0 and 1. A distance value of 0 means the strings are not similar at all and a distance value of 1 means that the strings are really similar.

Write a function jaro_distance(s1,s2) which calculates the Jaro distance between the given two strings.

##### Sample Input:

`s1: arow`

<class 'str'>

`s2: arrow`

##### Expected Output:

`0.9333333333333332`

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

##### This is a premium feature.

To access this and other such features, click on upgrade below.

Input Test Case

Please enter only one test case at a timenumpy has been already imported as np (import numpy as np)