MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / get_matched_characters

Function get_matched_characters

strings/jaro_winkler.py:28–40  ·  view source on GitHub ↗
(_str1: str, _str2: str)

Source from the content-addressed store, hash-verified

26 """
27
28 def get_matched_characters(_str1: str, _str2: str) -> str:
29 matched = []
30 limit = min(len(_str1), len(_str2)) // 2
31 for i, char in enumerate(_str1):
32 left = int(max(0, i - limit))
33 right = int(min(i + limit + 1, len(_str2)))
34 if char in _str2[left:right]:
35 matched.append(char)
36 _str2 = (
37 f"{_str2[0 : _str2.index(char)]} {_str2[_str2.index(char) + 1 :]}"
38 )
39
40 return "".join(matched)
41
42 # matching characters
43 matching_1 = get_matched_characters(str1, str2)

Callers 1

jaro_winklerFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected