Subversion Repositories navi

Rev

Rev 133 | Rev 135 | 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
 
133 szabot 15
numord = [u"kewve",
16
          u"'awve",
17
          u"muve",
18
          u"pxeyve",
19
          u"tsìve",
20
          u"mrrve",
21
          u"puve",
22
          u"kive"]
23
 
2 szabot 24
rem = [u"aw",
25
       u"mun",
26
       u"pey",
27
       u"sìng",
28
       u"mrr",
29
       u"fu",
30
       u"hin"]
31
 
133 szabot 32
remord = [u"awve",
33
       u"muve",
34
       u"peyve",
35
       u"sìve",
36
       u"mrrve",
37
       u"fuve",
38
       u"hive"]
39
 
2 szabot 40
base = [u"",
41
        u"me",
42
        u"pxe",
43
        u"tsì",
44
        u"mrr",
45
        u"pu",
46
        u"ki"]
47
 
48
 
49
numre = \
133 szabot 50
      u"^(a?)(?:(?:(" + "|".join(base) + u")zaza(?=m)(?:ve(?=$))?)?" + \
51
      u"(?:(" + "|".join(base) + u")voza(?=m)(?:ve(?=$))?)?" + \
52
      u"(?:(" + "|".join(base) + u")za(?=m)(?:ve(?=$))?)?" + \
53
      u"(?:(" + "|".join(base) + u")(?:vol|vo(?=a|$))(?:ve(?=$))?)?" + \
134 szabot 54
      u"(?:(" + "|".join(remord + rem) + u")))|" + \
55
      u"(?:(" + "|".join(numord + num) + u"))?(a?)$"
2 szabot 56
numre = re.compile(numre)
57
 
58
def parse(numin):
118 szabot 59
    if numin in (u"a", u"aa", u"ave", u"avea", u"ve", u"vea"):
60
        return None
2 szabot 61
    try:
62
        mat = numre.match(numin).groups()
63
    except:
64
        return None
65
    numout = 0
66
    numoct = 0
67
    try:
103 szabot 68
        numout += rem.index(mat[5]) + 1
69
        numoct += rem.index(mat[5]) + 1
2 szabot 70
    except:
71
        try:
134 szabot 72
            numout += num.index(mat[6])
73
            numoct += num.index(mat[6])
2 szabot 74
        except: pass
75
    try:
103 szabot 76
        numout += (base.index(mat[4]) + 1) * 8
77
        numoct += (base.index(mat[4]) + 1) * 10
2 szabot 78
    except: pass
79
    try:
103 szabot 80
        numout += (base.index(mat[3]) + 1) * 8**2
81
        numoct += (base.index(mat[3]) + 1) * 10**2
2 szabot 82
    except: pass
83
    try:
103 szabot 84
        numout += (base.index(mat[2]) + 1) * 8**3
85
        numoct += (base.index(mat[2]) + 1) * 10**3
2 szabot 86
    except: pass
87
    try:
103 szabot 88
        numout += (base.index(mat[1]) + 1) * 8**4
89
        numoct += (base.index(mat[1]) + 1) * 10**4
2 szabot 90
    except: pass
103 szabot 91
    retnum = unicode(numout)
92
    if mat[6] != u"":
93
        retnum += u"."
106 szabot 94
    prefs = []
95
    posts = []
96
    if mat[0] != u"":
97
        prefs.append(mat[0])
98
    if mat[7] != u"":
99
        posts.append(mat[7])
134 szabot 100
    if "ve" in numin:
101
        posts.append("ve")
109 szabot 102
    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 103
    #return numout, numoct
2 szabot 104
 
105
 
106
if __name__ == "__main__":
106 szabot 107
    print parse(u"mrrvolawvea")