Subversion Repositories navi

Rev

Rev 71 | Rev 73 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 szabot 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
 
4
import re
66 szabot 5
import dbconnector
56 szabot 6
 
65 szabot 7
wordlist = dbconnector.getnavilist()
8
 
9
infixes1 = [u"awn", u"eyk", u"us", u"äp", u""]
10
infixes2 = [u"ìyev", u"iyev", u"ìmìy", u"arm", u"asy", u"ilv", u"ìmv", u"imv", u"ìrm", u"irv", u"ìsy", u"aly", u"ary", u"ìly", u"ìry", u"ìlm", u"alm", u"am", u"ay", u"er", u"ìm", u"iv", u"ìy", u"ol", u""]
11
infixes3 = [u"äng", u"ats", u"eiy", u"ei", u"uy", u""]
62 szabot 12
#prefixesn = ur"(?P<npr>(?:(?:fì|tsa)?(?:me|pxe|ay|fra)?|(?:fay)?|(?:tsay)?)(?:fne)?(?:tì|sä)?"
65 szabot 13
prefixes = [u"ay", u"me", u"pxe", u"pe", u"a", u"le", u"nì", u"sä", u"tì", u"ke", u"fì", u"fay", u"tsa", u"tsay", u"fra"]
62 szabot 14
#postfixesv = ur"(?P<vpr>(?:nì|sä|tì|rä'ä |ke )?)"
56 szabot 15
 
16
def parseword(wordin):
70 szabot 17
    ret = {"word": {"id": 0, "navi": u" ".join(wordin), "infix": u"", "type": u""}}
65 szabot 18
    foundword = u""
19
    for word in wordlist:
69 szabot 20
        foundinf = False
65 szabot 21
        foundit = True
22
        foundprefs = []
23
        foundposts = []
24
        splitword = word["infix"].split(" ")
72 szabot 25
        if len(wordin) == len(splitword):
68 szabot 26
            foundit = False
27
            next
65 szabot 28
        for wor in range(len(splitword)):
29
            foundprefs.append([])
30
            foundposts.append([])
31
            center = u""
32
            foundins = [u"", u"", u""]
33
            pre = []
34
            post = []
35
            found = False
36
            if u"<1>" in splitword[wor]:
37
                for in1 in infixes1:
38
                    for in2 in infixes2:
39
                        for in3 in infixes3:
40
                            if splitword[wor].replace(u"<1><2>",in1+in2).replace(u"<3>",in3) in wordin[wor]:
41
                                center = splitword[wor].replace(u"<1><2>",in1+in2).replace(u"<3>",in3)
42
                                foundins = [in1, in2, in3]
43
                                foundinf = True
44
                                break
45
                        if foundinf: break
46
                    if foundinf: break
47
            else:
48
                if splitword[wor] in wordin[wor]:
49
                    center = splitword[wor]
50
                    foundinf = True
51
            if not foundinf:
52
                foundit = False
53
                break
69 szabot 54
            pref, posf = wordin[wor].split(center)
65 szabot 55
            for pre in prefixes:
56
                if pref.endswith(pre):
57
                    foundprefs[wor].append(pre)
58
                    pref = pref[:len(pref)-len(pre)]
59
            if pref != u"":
60
                foundit = False
61
                break
62
            foundposts[wor] = posf
63
        if foundit == True:
64
            foundword = word
56 szabot 65
            break
65 szabot 66
    if foundit == True:
71 szabot 67
        ret["pref"] = foundprefs
68
        ret["post"] = foundposts
69
        ret["inf"] = foundins
70
        ret["word"] = foundword
70 szabot 71
    return ret