Levenshtein距離
Abstract
Explanation
TODO まだ.
Implementation
Input
文字列$ S, T
Output
文字列$ S, T間のLevenshtein距離$ d_{\mathrm{L}}(S, T)
Time complexity
$ O(|S| |T|)time.
code:python
def levenshtein_dist(S, T):
'''
Input:
S, T: string
Output:
the Levenshtein distance of S and T
'''
len_S, len_T = len(S), len(T)
for i in range(len_S + 1): dpi0 = i for j in range(len_T + 1): dp0j = j for i in range(1, len_S + 1):
for j in range(1, len_T + 1):
Verification
なし
References