Grammalecte  Diff

Differences From Artifact [47f74994c2]:

To Artifact [faeb79ed1d]:


1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


26

27
28
29
30
31
32
33
...
103
104
105
106
107
108
109
110
111
112
113
#! python3
#
# Metagraphe
#
# By Olivier R. - 2013

import re
import unicodedata


# Dictionnaire des caractères pour la phonétique         
PHMAP = str.maketrans({ 'à': 'a',  'â': 'a',  'ä': 'a',  'å': 'a',  'ā': 'a',
                        'ç': 'S',
                        'é': 'é',  'è': 'é',  'ê': 'é',  'ë': 'é',  'ē': 'é',
                        'î': 'i',  'ï': 'i',  'ī': 'i', 
                        'ñ': 'ni',
                        'ô': 'o',  'ö': 'o',  'ō': 'o',
                        'ù': 'u',  'û': 'u',  'ü': 'u',  'ū': 'u',
                        'ÿ': 'i',
                        'æ': 'é' })

def getPhonex (s, sMorph):
    "returns a simplified phonetic string"
    s = s.lower().translate(PHMAP)
    if re.match("[A-Z0-9]+$", s) or len(s) == 1:
        return s


    else:

        s = re.sub("sc(?=[eéiy])", "S", s)
        s = re.sub("x[cs](?=[eéiy])", "kS", s)
        s = re.sub("c(?=[eéiy])", "S", s)
        s = re.sub("c(?=[auoœ])", "k", s)
        s = re.sub("ge(?=[ao])", "j", s)
        s = re.sub("g(?=[ieéy])", "j", s)
        s = re.sub("gue", "ge", s)
................................................................................
def getGraphix (s):
    "returns a simplified spelling"
    return ''


def getMetagraphe (s, sMorph):
    return (getPhonex(s, sMorph), getGraphix(s))

if __name__ == '__main__':
    import doctest
    doctest.testmod()







<

>
|



|








<
|

>
>

>







 







<
<
<
<
1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
...
105
106
107
108
109
110
111




#! python3
#
# Metagraphe
#
# By Olivier R. - 2013

import re



# Dictionnaire des caractères pour la phonétique
PHMAP = str.maketrans({ 'à': 'a',  'â': 'a',  'ä': 'a',  'å': 'a',  'ā': 'a',
                        'ç': 'S',
                        'é': 'é',  'è': 'é',  'ê': 'é',  'ë': 'é',  'ē': 'é',
                        'î': 'i',  'ï': 'i',  'ī': 'i',
                        'ñ': 'ni',
                        'ô': 'o',  'ö': 'o',  'ō': 'o',
                        'ù': 'u',  'û': 'u',  'ü': 'u',  'ū': 'u',
                        'ÿ': 'i',
                        'æ': 'é' })

def getPhonex (s, sMorph):
    "returns a simplified phonetic string"

    if re.match("[A-Z0-9]{2,}$", s):
        return s
    elif len(s) == 1:
        return s.lower().translate(PHMAP)
    else:
        s = s.lower().translate(PHMAP)
        s = re.sub("sc(?=[eéiy])", "S", s)
        s = re.sub("x[cs](?=[eéiy])", "kS", s)
        s = re.sub("c(?=[eéiy])", "S", s)
        s = re.sub("c(?=[auoœ])", "k", s)
        s = re.sub("ge(?=[ao])", "j", s)
        s = re.sub("g(?=[ieéy])", "j", s)
        s = re.sub("gue", "ge", s)
................................................................................
def getGraphix (s):
    "returns a simplified spelling"
    return ''


def getMetagraphe (s, sMorph):
    return (getPhonex(s, sMorph), getGraphix(s))