Grammalecte  Diff

Differences From Artifact [c5501f9a5a]:

To Artifact [7dcad03ac9]:


1
2
3
4
5
6
7







8
9
10
11
12
13
14
#!python3

"""
Operations on strings:
- calculate distance between two strings
- transform strings with transformation codes
"""









#### DISTANCE CALCULATIONS

def longestCommonSubstring (s1, s2):
    "longest common substring"
    # http://en.wikipedia.org/wiki/Longest_common_substring_problem
<
<





>
>
>
>
>
>
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19


"""
Operations on strings:
- calculate distance between two strings
- transform strings with transformation codes
"""

#### Ngrams

def getNgrams (sWord, n=2):
    "return a list of Ngrams strings"
    return [ sWord[i:i+n]  for i in range(len(sWord)-n+1) ]



#### DISTANCE CALCULATIONS

def longestCommonSubstring (s1, s2):
    "longest common substring"
    # http://en.wikipedia.org/wiki/Longest_common_substring_problem