Rev 115 | Rev 118 | 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 |
||
117 | szabot | 46 | if mat[5] == u"" and mat[4] == u"" and mat[3] == u"" and mat[2] == u"" and mat[1] == u"": |
115 | muzer | 47 | return None |
2 | szabot | 48 | numout = 0 |
49 | numoct = 0 |
||
50 | try: |
||
103 | szabot | 51 | numout += rem.index(mat[5]) + 1 |
52 | numoct += rem.index(mat[5]) + 1 |
||
2 | szabot | 53 | except: |
54 | try: |
||
103 | szabot | 55 | numout += num.index(mat[5]) |
56 | numoct += num.index(mat[5]) |
||
2 | szabot | 57 | except: pass |
58 | try: |
||
103 | szabot | 59 | numout += (base.index(mat[4]) + 1) * 8 |
60 | numoct += (base.index(mat[4]) + 1) * 10 |
||
2 | szabot | 61 | except: pass |
62 | try: |
||
103 | szabot | 63 | numout += (base.index(mat[3]) + 1) * 8**2 |
64 | numoct += (base.index(mat[3]) + 1) * 10**2 |
||
2 | szabot | 65 | except: pass |
66 | try: |
||
103 | szabot | 67 | numout += (base.index(mat[2]) + 1) * 8**3 |
68 | numoct += (base.index(mat[2]) + 1) * 10**3 |
||
2 | szabot | 69 | except: pass |
70 | try: |
||
103 | szabot | 71 | numout += (base.index(mat[1]) + 1) * 8**4 |
72 | numoct += (base.index(mat[1]) + 1) * 10**4 |
||
2 | szabot | 73 | except: pass |
103 | szabot | 74 | retnum = unicode(numout) |
75 | if mat[6] != u"": |
||
76 | retnum += u"." |
||
106 | szabot | 77 | prefs = [] |
78 | posts = [] |
||
79 | if mat[0] != u"": |
||
80 | prefs.append(mat[0]) |
||
81 | if mat[6] != u"": |
||
82 | posts.append(mat[6]) |
||
83 | if mat[7] != u"": |
||
84 | posts.append(mat[7]) |
||
109 | szabot | 85 | 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 | 86 | #return numout, numoct |
2 | szabot | 87 | |
88 | |||
89 | if __name__ == "__main__": |
||
106 | szabot | 90 | print parse(u"mrrvolawvea") |