Rev 169 | Rev 171 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
159 | muzer | 1 | # -*- coding: utf-8 -*- |
146 | szabot | 2 | import parse |
151 | szabot | 3 | import dbconnector |
158 | muzer | 4 | |
5 | infixes1 = ((u"awn", u"P.PART"), (u"eyk", u"CAUS"), (u"us", u"A.PART"), (u"äp", u"REFL.")) |
||
6 | infixes2 = ((u"ìyev", u"FUT.SUBJ"), (u"iyev", u"FUT.SUBJ"), (u"ìmìy", u"REC.PAST.REC.FUT"), (u"arm", u"IMPF.PAST"), (u"asy", u"FUT.D"), (u"ilv", u"PRES.PER.SUBJ"), (u"ìmv", u"REC.PAST.SUBJ"), (u"imv", u"PAST.SUBJ"), (u"ìrm", u"IMPF.REC.PAST"), (u"irv", u"PRES.IMPF.SUBJ"), (u"ìsy", u"IMM.FUT.D"), (u"aly", u"PERF.FUT"), (u"ary", u"IMPF.FUT"), (u"ìly", u"PERF.IMM.FUT"), (u"ìry", u"IMPF.IMM.FUT"), (u"ìlm", u"PERF.REC.PAST"), (u"alm", u"PERF.PAST"), (u"am", u"PAST."), (u"ay", u"FUT."), (u"er", u"IMPF."), (u"ìm", u"REC.PAST"), (u"iv", u"SUBJ."), (u"ìy", u"IMM.FUT"), (u"ol", u"PERF.")) |
||
7 | infixes3 = ((u"äng", u"PEJ."), (u"ats", u"INFR."), (u"eiy", u"LAUD."), (u"ei", u"LAUD."), (u"uy", u"HON.")) |
||
170 | muzer | 8 | prefixes = ((u"tsay", u"those"), (u"say", u"those-LENTD"), (u"fay", u"these"), (u"fra", u"every"), (u"pxe", u"TRI."), (u"fne", u"type"), (u"tsa", u"that"), (u"sa", u"that-LENTD"), (u"pe", u"what"), (u"fe", u"what-LENTD"), (u"le", u"ADJD."), (u"nì", u"ADVD."), (u"sä", u"INSTD."), (u"tì", u"NOUND."), (u"sì", u"NOUND.-LENTD"), (u"ay", u"PL."), (u"me", u"DU."), (u"fì", u"this"), (u"ke", u"not"), (u"he", u"not-LENTD"), (u"a", u"ADJ.POST")) |
158 | muzer | 9 | adpositions = ((u"mungwrr", u"except"), (u"kxamlä", u"through"), (u"pximaw", u"right.after"), (u"pxisre", u"right.before"), (u"tafkip", u"from.up.among"), (u"nemfa", u"into.inside"), (u"takip", u"from among"), (u"mìkam", u"between"), (u"teri", u"about.concerning"), (u"fkip", u"up.among"), (u"luke", u"without"), (u"pxel", u"like.as"), (u"pxaw", u"around"), (u"rofa", u"beside.alongside"), (u"ìlä", u"by.via.following"), (u"fpi", u"for.the.sake/benefit.of"), (u"ftu", u"from.direction"), (u"kip", u"among"), (u"lok", u"close.to"), (u"maw", u"after.time"), (u"sre", u"before.time"), (u"sìn", u"on.onto"), (u"vay", u"up.to"), (u"eo", u"before.in.front.of"), (u"fa", u"with.by.means.of"), (u"hu", u"with.accompaniment"), (u"io", u"above"), (u"ka", u"across"), (u"mì", u"in.on"), (u"na", u"like.as"), (u"ne", u"to.towards"), (u"ro", u"at.locative"), (u"ta", u"from"), (u"uo", u"behind"), (u"wä", u"against.opposition"), (u"äo", u"below"), (u"to", u"than")) |
170 | muzer | 10 | postfixes = adpositions + ((u"tsyìp", u"DIM."), (u"eyä", u"GEN."), (u"ìri", u"TOP."), (u"ìl", u"ERG."), (u"it", u"ACC"), (u"lo", u"MULT."), (u"ri", u"TOP."), (u"ru", u"DAT."), (u"ti", u"ACC."), (u"ur", u"DAT."), (u"ve", u"ORD."), (u"yä", u"GEN."), (u"ya", u"VOC."), (u"tu", u"OBJD."), (u"vi", u"PART."), (u"yu", u"AGENTD."), (u"an", u"MASC."), (u"ng", u"INCL."), (u"ke", u"not"), (u"e", u"FEM."), (u"o", u"INDEF."), (u"l", u"ERG."), (u"t", u"ACC."), (u"y", u"GEN."), (u"a", u"ADJ.PRE"), (u"ä", u"GEN."), (u"r", u"DAT.")) |
158 | muzer | 11 | |
146 | szabot | 12 | def translatesent(sent, lang): |
13 | sent = parse.parsesent(sent) |
||
14 | for word in sent: |
||
15 | if word["word"]["id"] != 0: |
||
16 | word["translated"] = dbconnector.translate(word["word"]["id"],lang) |
||
17 | else: |
||
18 | word["translated"] = word["word"]["navi"] |
||
158 | muzer | 19 | if word["inf"][0] != u"": |
20 | for fix in infixes1: |
||
21 | if fix[0] == word["inf"][0]: |
||
162 | muzer | 22 | word["translated"] += '-' + fix[1] |
158 | muzer | 23 | if word["inf"][1] != u"": |
24 | for fix in infixes2: |
||
25 | if fix[0] == word["inf"][1]: |
||
162 | muzer | 26 | word["translated"] += '-' + fix[1] |
158 | muzer | 27 | if word["inf"][2] != u"": |
28 | for fix in infixes3: |
||
29 | if fix[0] == word["inf"][2]: |
||
162 | muzer | 30 | word["translated"] += '-' + fix[1] |
169 | muzer | 31 | for temp in word["pref"]: # double array? WTF? |
32 | for navf in temp: |
||
33 | for fix in prefixes: |
||
34 | if fix[0] == navf: |
||
35 | word["translated"] += '-' + fix[1] |
||
36 | for temp in word["post"]: # double array? WTF? |
||
37 | for navf in temp: |
||
38 | for fix in postfixes: |
||
39 | if fix[0] == navf: |
||
40 | word["translated"] += '-' + fix[1] |
||
163 | muzer | 41 | if word["len"]: |
42 | word["translated"] += '-' + 'LENTD' |
||
158 | muzer | 43 | return sent |