Subversion Repositories navi

Rev

Rev 103 | Rev 105 | 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")|" + \
103 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"."
75
    return {"word": {"id": 0, "navi": retnum, "infix": u"", "type": u""}, "pref": [mat[0]], "post": [mat[6], mat[7]], "inf": [u"", u"", u""], "len": False, "dec": numout, "oct": numdec}
76
    #return numout, numoct
2 szabot 77
 
78
 
79
if __name__ == "__main__":
80
    print parse(u"mrrvolaw")