Grammalecte  Check-in [874cb415e9]

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 on 2018-10-05 20:22:57
Other Links: manifest | tags
Context
2018-10-06
13:46
[fr] passation de pouvoir check-in: 4292f525f4 user: olr tags: trunk, fr
2018-10-05
20:22
[graphspell] str_transform: function getNgrams() check-in: 874cb415e9 user: olr tags: trunk, graphspell
2018-10-01
19:04
[fr] faux positifs divers check-in: 61dd49433d user: olr tags: trunk, fr
Changes

Modified graphspell-js/str_transform.js from [7b239f9b34] to [63ae767339].

1
2
3
4
5
6
7
8
9








10
11
12
13
14
15
16
//// STRING TRANSFORMATION
/*jslint esversion: 6*/

"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;









>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//// STRING TRANSFORMATION
/*jslint esversion: 6*/

"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;

Modified graphspell/str_transform.py from [c5501f9a5a] to [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