Rev 141 | Rev 147 | 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 |
||
146 | szabot | 67 | if u"ve" in posts: |
68 | for n in range(len(num)): |
||
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 | for n in range(len(num)): |
||
78 | if numin == num[n]: |
||
79 | outoct = n |
||
80 | outdec = n |
||
81 | ret["word"]["navi"] = unicode(outdec) |
||
82 | ret["dec"] = outdec |
||
83 | ret["oct"] = outoct |
||
84 | return ret |
||
138 | szabot | 85 | #other numbers |
86 | for n in range(len(base)): |
||
87 | if numin.startswith(base[n] + u"zazam"): |
||
88 | outoct += (n+1) * (10**4) |
||
89 | outdec += (n+1) * (8**4) |
||
90 | numin = numin[len(base[n]) + 5:] |
||
91 | for n in range(len(base)): |
||
92 | if numin.startswith(base[n] + u"vozam"): |
||
93 | outoct += (n+1) * (10**3) |
||
94 | outdec += (n+1) * (8**3) |
||
95 | numin = numin[len(base[n]) + 5:] |
||
96 | for n in range(len(base)): |
||
97 | if numin.startswith(base[n] + u"zam"): |
||
98 | outoct += (n+1) * (10**2) |
||
99 | outdec += (n+1) * (8**2) |
||
100 | numin = numin[len(base[n]) + 3:] |
||
101 | for n in range(len(base)): |
||
102 | if numin.startswith(base[n] + u"vol"): |
||
103 | outoct += (n+1) * 10 |
||
104 | outdec += (n+1) * 8 |
||
105 | numin = numin[len(base[n]) + 3:] |
||
106 | if numin.startswith(base[n] + u"vo"): |
||
107 | outoct += (n+1) * 10 |
||
108 | outdec += (n+1) * 8 |
||
109 | numin = numin[len(base[n]) + 2:] |
||
110 | for n in range(len(rem)): |
||
111 | if u"ve" in posts: |
||
112 | if numin == remord[n]: |
||
113 | outoct += n + 1 |
||
114 | outdec += n + 1 |
||
115 | numin = u"" |
||
116 | else: |
||
117 | if numin == rem[n]: |
||
118 | outoct += n + 1 |
||
119 | outdec += n + 1 |
||
120 | numin = u"" |
||
121 | if numin == u"": |
||
122 | ret["word"]["navi"] = unicode(outdec) if not u"ve" in posts else unicode(outdec) + u"." |
||
123 | ret["dec"] = outdec |
||
124 | ret["oct"] = outoct |
||
125 | return ret |
||
126 | else: |
||
141 | szabot | 127 | return None |
138 | szabot | 128 | |
129 | if __name__ == "__main__": |
||
130 | print parse(u"mevolawve") |