Subversion Repositories navi

Rev

Rev 176 | Rev 205 | 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 -*-
176 muzer 3
#    This file is part of Tsim Apiak.
4
#
5
#    Tsim Apiak is free software: you can redistribute it and/or modify
6
#    it under the terms of the GNU General Public Licence as published by
7
#    the Free Software Foundation, either version 3 of the Licence, or
8
#    (at your option) any later version. 
9
# 
10
#    In addition to this, you must also comply with clause 4 of the
11
#    Apache Licence, version 2.0, concerning attribution. Where there
12
#    is a contradiction between the two licences, the GPL
13
#    takes preference.
14
#
186 szabot 15
#    Tsim Apiak is distributed in the hope that it will be useful,
176 muzer 16
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
#    GNU General Public License for more details.
19
#
20
#    You should have received a copy of the GNU General Public License
21
#    along with Tsim Apiak.  If not, see <http://www.gnu.org/licenses/>.
138 szabot 22
 
23
num = [u"kew",
24
       u"'aw",
25
       u"mune",
26
       u"pxey",
27
       u"tsìng",
28
       u"mrr",
29
       u"pukap",
30
       u"kinä"]
31
 
32
numord = [u"kew",
33
          u"'aw",
34
          u"mu",
35
          u"pxey",
36
          u"tsì",
37
          u"mrr",
38
          u"pu",
39
          u"ki"]
40
 
41
rem = [u"aw",
42
       u"mun",
43
       u"pey",
44
       u"sìng",
45
       u"mrr",
46
       u"fu",
47
       u"hin"]
48
 
49
remord = [u"aw",
50
          u"mu",
51
          u"pey",
52
          u"sì",
53
          u"mrr",
54
          u"fu",
55
          u"hi"]
56
 
57
base = [u"",
58
        u"me",
59
        u"pxe",
60
        u"tsì",
61
        u"mrr",
62
        u"pu",
63
        u"ki"]
64
 
65
def parse(numin):
66
    if u"mm" in numin:
67
        return None
68
    if (numin[0] == u"a") and (numin[len(numin)-1] == u"a"):
69
        return None
70
    prefs = []
71
    posts = []
72
    outoct = 0
73
    outdec = 0
140 szabot 74
    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 75
    if numin[0] == u"a":
76
        prefs.append(u"a")
77
        numin = numin[1:]
149 szabot 78
    if numin[len(numin)-1] == u"a":
79
        posts.append(u"a")
80
        numin = numin[:-1]
138 szabot 81
    if numin[-2:] == u"ve":
82
        posts.append(u"ve")
83
        numin = numin[:-2]
84
 
85
    #base numbers
147 szabot 86
    for n in range(len(num)):
87
        if u"ve" in posts:
88
            if numin == numord[n]:
89
                outoct = n
90
                outdec = n
91
                ret["word"]["navi"] = unicode(outdec) + u"."
92
                ret["dec"] = outdec
93
                ret["oct"] = outoct
94
                return ret
95
        else:
96
            if numin == num[n]:
97
                outoct = n
98
                outdec = n
99
                ret["word"]["navi"] = unicode(outdec)
100
                ret["dec"] = outdec
101
                ret["oct"] = outoct
102
                return ret
138 szabot 103
    #other numbers
104
    for n in range(len(base)):
105
        if numin.startswith(base[n] + u"zazam"):
106
            outoct += (n+1) * (10**4)
107
            outdec += (n+1) * (8**4)
108
            numin = numin[len(base[n]) + 5:]
109
    for n in range(len(base)):
110
        if numin.startswith(base[n] + u"vozam"):
111
            outoct += (n+1) * (10**3)
112
            outdec += (n+1) * (8**3)
113
            numin = numin[len(base[n]) + 5:]
114
    for n in range(len(base)):
115
        if numin.startswith(base[n] + u"zam"):
116
            outoct += (n+1) * (10**2)
117
            outdec += (n+1) * (8**2)
118
            numin = numin[len(base[n]) + 3:]
119
    for n in range(len(base)):
120
        if numin.startswith(base[n] + u"vol"):
121
            outoct += (n+1) * 10
122
            outdec += (n+1) * 8
123
            numin = numin[len(base[n]) + 3:]
124
        if numin.startswith(base[n] + u"vo"):
125
            outoct += (n+1) * 10
126
            outdec += (n+1) * 8
127
            numin = numin[len(base[n]) + 2:]
128
    for n in range(len(rem)):
129
        if u"ve" in posts:
130
            if numin == remord[n]:
131
                outoct += n + 1
132
                outdec += n + 1
133
                numin = u""
134
        else:
135
            if numin == rem[n]:
136
                outoct += n + 1
137
                outdec += n + 1
138
                numin = u""
139
    if numin == u"":
140
        ret["word"]["navi"] = unicode(outdec) if not u"ve" in posts else unicode(outdec) + u"."
141
        ret["dec"] = outdec
142
        ret["oct"] = outoct
143
        return ret
144
    else:
141 szabot 145
        return None
138 szabot 146
 
147
if __name__ == "__main__":
176 muzer 148
    print parse(u"mevolawve")