Subversion Repositories navi

Rev

Rev 106 | Rev 117 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 szabot 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
 
4
import re
5
 
6
num = [u"kew",
7
       u"'aw",
8
       u"mune",
9
       u"pxey",
10
       u"tsìng",
11
       u"mrr",
12
       u"pukap",
13
       u"kinä"]
14
 
15
rem = [u"aw",
16
       u"mun",
17
       u"pey",
18
       u"sìng",
19
       u"mrr",
20
       u"fu",
21
       u"hin"]
22
 
23
base = [u"",
24
        u"me",
25
        u"pxe",
26
        u"tsì",
27
        u"mrr",
28
        u"pu",
29
        u"ki"]
30
 
31
 
32
numre = \
103 szabot 33
      u"^(a?)(?:(" + "|".join(base) + u")zazam??)?" + \
2 szabot 34
      u"(?:(" + "|".join(base) + u")vozam??)?" + \
35
      u"(?:(" + "|".join(base) + u")zam??)?" + \
36
      u"(?:(" + "|".join(base) + u")vo(?:l(?=a|))?)?" + \
37
      u"((?:" + "|".join(rem) + u")|" + \
105 szabot 38
      u"(?:" + "|".join(num) + u"))?((?:ve)?)(a?)$"
2 szabot 39
numre = re.compile(numre)
40
 
41
def parse(numin):
42
    try:
43
        mat = numre.match(numin).groups()
44
    except:
45
        return None
46
    numout = 0
47
    numoct = 0
48
    try:
103 szabot 49
        numout += rem.index(mat[5]) + 1
50
        numoct += rem.index(mat[5]) + 1
2 szabot 51
    except:
52
        try:
103 szabot 53
            numout += num.index(mat[5])
54
            numoct += num.index(mat[5])
2 szabot 55
        except: pass
56
    try:
103 szabot 57
        numout += (base.index(mat[4]) + 1) * 8
58
        numoct += (base.index(mat[4]) + 1) * 10
2 szabot 59
    except: pass
60
    try:
103 szabot 61
        numout += (base.index(mat[3]) + 1) * 8**2
62
        numoct += (base.index(mat[3]) + 1) * 10**2
2 szabot 63
    except: pass
64
    try:
103 szabot 65
        numout += (base.index(mat[2]) + 1) * 8**3
66
        numoct += (base.index(mat[2]) + 1) * 10**3
2 szabot 67
    except: pass
68
    try:
103 szabot 69
        numout += (base.index(mat[1]) + 1) * 8**4
70
        numoct += (base.index(mat[1]) + 1) * 10**4
2 szabot 71
    except: pass
103 szabot 72
    retnum = unicode(numout)
73
    if mat[6] != u"":
74
        retnum += u"."
106 szabot 75
    prefs = []
76
    posts = []
77
    if mat[0] != u"":
78
        prefs.append(mat[0])
79
    if mat[6] != u"":
80
        posts.append(mat[6])
81
    if mat[7] != u"":
82
        posts.append(mat[7])
109 szabot 83
    return {"word": {"id": 0, "navi": retnum, "infix": u"", "type": u""}, "pref": [prefs], "post": [posts], "inf": [u"", u"", u""], "len": False, "dec": numout, "oct": numoct}
103 szabot 84
    #return numout, numoct
2 szabot 85
 
86
 
87
if __name__ == "__main__":
106 szabot 88
    print parse(u"mrrvolawvea")