File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
shorttext/metrics/dynprog Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 44
55
66@nb .njit
7- def damerau_levenshtein (word1 , word2 ):
7+ def damerau_levenshtein (word1 : str , word2 : str ) -> int :
8+ """ Calculate the Demarau-Levenshtein (DL) distance between two words.
9+
10+ :param word1: first word
11+ :param word2: seccond word
12+ :return: Damerau-Levenshtein (DL) distance
13+ :type word1: str
14+ :type word2: str
15+ :rtype: int
16+ """
817 len1 = len (word1 )
918 len2 = len (word2 )
1019 matrix = np .zeros ((len1 + 1 , len2 + 1 ), dtype = np .int8 )
Original file line number Diff line number Diff line change 44
55@nb .njit
66def longest_common_prefix (word1 : str , word2 : str ) -> int :
7+ """ Calculate the longest common prefix (LCP) between two words.
8+
9+ :param word1: first word
10+ :param word2: seccond word
11+ :return: longest common prefix (LCP)
12+ :type word1: str
13+ :type word2: str
14+ :rtype: int
15+ """
716 lcp = 0
817 for i in range (min (len (word1 ), len (word2 ))):
918 if word1 [i ] == word2 [i ]:
You can’t perform that action at this time.
0 commit comments