Grammalecte  Check-in [874cb415e9]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[graphspell] str_transform: function getNgrams()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256:874cb415e9b2270395320dcdc53c31661b6ddc112d66ec993348688bee185a3d
User & Date: olr 2018-10-05 20:22:57
Context
2018-10-06
13:46
[fr] passation de pouvoir check-in: 4292f525f4 user: olr tags: fr, trunk
2018-10-05
20:22
[graphspell] str_transform: function getNgrams() check-in: 874cb415e9 user: olr tags: graphspell, trunk
2018-10-01
19:04
[fr] faux positifs divers check-in: 61dd49433d user: olr tags: fr, trunk
Changes

Changes to graphspell-js/str_transform.js.

3
4
5
6
7
8
9








10
11
12
13
14
15
16

"use strict";


// Note: 48 is the ASCII code for "0"

var str_transform = {









    longestCommonSubstring: function (string1, string2) {
        // https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring
        // untested

        // init max value
        let longestCommonSubstring = 0;







>
>
>
>
>
>
>
>







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

"use strict";


// Note: 48 is the ASCII code for "0"

var str_transform = {

    getNgrams: function (sWord, n=2) {
        let lNgrams = [];
        for (let i=0;  i <= sWord.length - n;  i++) {
            lNgrams.push(sWord.slice(i, i+n));
        }
        return lNgrams;
    },

    longestCommonSubstring: function (string1, string2) {
        // https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring
        // untested

        // init max value
        let longestCommonSubstring = 0;

Changes to graphspell/str_transform.py.

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