Rev 146 | Rev 176 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
138 | szabot | 1 | #!/usr/bin/python |
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | num = [u"kew", |
||
5 | u"'aw", |
||
6 | u"mune", |
||
7 | u"pxey", |
||
8 | u"tsìng", |
||
9 | u"mrr", |
||
10 | u"pukap", |
||
11 | u"kinä"] |
||
12 | |||
13 | numord = [u"kew", |
||
14 | u"'aw", |
||
15 | u"mu", |
||
16 | u"pxey", |
||
17 | u"tsì", |
||
18 | u"mrr", |
||
19 | u"pu", |
||
20 | u"ki"] |
||
21 | |||
22 | rem = [u"aw", |
||
23 | u"mun", |
||
24 | u"pey", |
||
25 | u"sìng", |
||
26 | u"mrr", |
||
27 | u"fu", |
||
28 | u"hin"] |
||
29 | |||
30 | remord = [u"aw", |
||
31 | u"mu", |
||
32 | u"pey", |
||
33 | u"sì", |
||
34 | u"mrr", |
||
35 | u"fu", |
||
36 | u"hi"] |
||
37 | |||
38 | base = [u"", |
||
39 | u"me", |
||
40 | u"pxe", |
||
41 | u"tsì", |
||
42 | u"mrr", |
||
43 | u"pu", |
||
44 | u"ki"] |
||
45 | |||
46 | def parse(numin): |
||
47 | if u"mm" in numin: |
||
48 | return None |
||
49 | if (numin[0] == u"a") and (numin[len(numin)-1] == u"a"): |
||
50 | return None |
||
51 | prefs = [] |
||
52 | posts = [] |
||
53 | outoct = 0 |
||
54 | outdec = 0 |
||
140 | szabot | 55 | ret = {"word": {"id": 0, "navi": u"", "infix": u"", "type": u""}, "pref": [prefs], "post": [posts], "inf": [u"", u"", u""], "len": False, "dec": outdec, "oct": outoct} |
138 | szabot | 56 | if numin[0] == u"a": |
57 | prefs.append(u"a") |
||
58 | numin = numin[1:] |
||
59 | if numin[-2:] == u"ve": |
||
60 | posts.append(u"ve") |
||
61 | numin = numin[:-2] |
||
62 | if numin[len(numin)-1] == u"a": |
||
63 | posts.append(u"a") |
||
64 | numin = numin[:-1] |
||
65 | |||
66 | #base numbers |
||
147 | szabot | 67 | for n in range(len(num)): |
68 | if u"ve" in posts: |
||
69 | if numin == numord[n]: |
||
70 | outoct = n |
||
71 | outdec = n |
||
72 | ret["word"]["navi"] = unicode(outdec) + u"." |
||
73 | ret["dec"] = outdec |
||
74 | ret["oct"] = outoct |
||
75 | return ret |
||
76 | else: |
||
77 | if numin == num[n]: |
||
78 | outoct = n |
||
79 | outdec = n |
||
80 | ret["word"]["navi"] = unicode(outdec) |
||
81 | ret["dec"] = outdec |
||
82 | ret["oct"] = outoct |
||
83 | return ret |
||
138 | szabot | 84 | #other numbers |
85 | for n in range(len(base)): |
||
86 | if numin.startswith(base[n] + u"zazam"): |
||
87 | outoct += (n+1) * (10**4) |
||
88 | outdec += (n+1) * (8**4) |
||
89 | numin = numin[len(base[n]) + 5:] |
||
90 | for n in range(len(base)): |
||
91 | if numin.startswith(base[n] + u"vozam"): |
||
92 | outoct += (n+1) * (10**3) |
||
93 | outdec += (n+1) * (8**3) |
||
94 | numin = numin[len(base[n]) + 5:] |
||
95 | for n in range(len(base)): |
||
96 | if numin.startswith(base[n] + u"zam"): |
||
97 | outoct += (n+1) * (10**2) |
||
98 | outdec += (n+1) * (8**2) |
||
99 | numin = numin[len(base[n]) + 3:] |
||
100 | for n in range(len(base)): |
||
101 | if numin.startswith(base[n] + u"vol"): |
||
102 | outoct += (n+1) * 10 |
||
103 | outdec += (n+1) * 8 |
||
104 | numin = numin[len(base[n]) + 3:] |
||
105 | if numin.startswith(base[n] + u"vo"): |
||
106 | outoct += (n+1) * 10 |
||
107 | outdec += (n+1) * 8 |
||
108 | numin = numin[len(base[n]) + 2:] |
||
109 | for n in range(len(rem)): |
||
110 | if u"ve" in posts: |
||
111 | if numin == remord[n]: |
||
112 | outoct += n + 1 |
||
113 | outdec += n + 1 |
||
114 | numin = u"" |
||
115 | else: |
||
116 | if numin == rem[n]: |
||
117 | outoct += n + 1 |
||
118 | outdec += n + 1 |
||
119 | numin = u"" |
||
120 | if numin == u"": |
||
121 | ret["word"]["navi"] = unicode(outdec) if not u"ve" in posts else unicode(outdec) + u"." |
||
122 | ret["dec"] = outdec |
||
123 | ret["oct"] = outoct |
||
124 | return ret |
||
125 | else: |
||
141 | szabot | 126 | return None |
138 | szabot | 127 | |
128 | if __name__ == "__main__": |
||
129 | print parse(u"mevolawve") |