Subversion Repositories navi

Rev

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