Subversion Repositories navi

Compare Revisions

Ignore whitespace Rev 65 → Rev 73

/tsimapiak/parse2.py
2,17 → 2,10
# -*- coding: utf-8 -*-
 
import re
#import dbconnector
import dbconnector
 
wordlist = dbconnector.getnavilist()
 
#wordlist = [{"id": 1, "navi": u"si", "infix": u"s<1><2><3>i", "type": u"v."},
#{"id": 2, "navi": u"wou", "infix": u"w<1><2>o<3>u", "type": u"v."},
#{"id": 3, "navi": u"kame", "infix": u"k<1><2>am<3>e", "type": u"v."},
#{"id": 4, "navi": u"tìng", "infix": u"t<1><2><3>ìng", "type": u"v."},
#{"id": 5, "navi": u"yerik", "infix": u"yerik", "type": u"n."},
#{"id": 6, "navi": u"nari", "infix": u"nari", "type": u"n."}]
 
infixes1 = [u"awn", u"eyk", u"us", u"äp", u""]
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""]
infixes3 = [u"äng", u"ats", u"eiy", u"ei", u"uy", u""]
21,18 → 14,18
#postfixesv = ur"(?P<vpr>(?:nì|sä|tì|rä'ä |ke )?)"
 
def parseword(wordin):
if type(wordin) == type(u"x"):
wordin = wordin.split(" ")
ret = {"word": {"id": 0, "navi": u" ".join(wordin), "infix": u"", "type": u""}}
foundword = u""
for word in wordlist:
foundinf = False
foundit = True
foundprefs = []
foundposts = []
splitword = word["infix"].split(" ")
if len(wordin) != len(splitword): next
if len(wordin) != len(splitword):
foundit = False
next
for wor in range(len(splitword)):
foundinf = False
foundprefs.append([])
foundposts.append([])
center = u""
58,7 → 51,7
if not foundinf:
foundit = False
break
pref, posf = wordin[wor].replace(center,u" ").split(" ")
pref, posf = wordin[wor].split(center)
for pre in prefixes:
if pref.endswith(pre):
foundprefs[wor].append(pre)
75,13 → 68,4
ret["post"] = foundposts
ret["inf"] = foundins
ret["word"] = foundword
return ret
 
#print(parseword([u"tìtìng"]))
#print(parseword([u"keykame"]))
#print(parseword([u"kameie"]))
#print(parseword([u"tìsusiti"]))
#print(parseword([u"weykayoeiu"]))
#print(parseword([u"yerikit"]))
#print(parseword([u"menari"]))
#print(parseword([u"menariri"]))
return ret
/tsimapiak/parse.py
26,7 → 26,7
regex = re.sub(u"<1><2>",u"[^ ]*",regex)
regex = re.sub(u"<3>",u"[^ ]*",regex)
if re.match(regex,original):
realword = eachword[2]
realword = eachword["infix"]
break
if realword == u"":
return [u"[" + original + u"]",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u"",u""]
/webapp/main.py
62,10 → 62,10
def post(self):
try:
word = self.get_argument("word").strip()
word = self.get_argument("word").strip(u" ")
except:
self.redirect("/parse2")
out = parse2.parseword(word)
out = parse2.parseword(word.split(u" "))
self.render("templates/parse2.html", last=word, out=out)
 
application = tornado.web.Application([
80,5 → 80,5
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(1337)
tornado.autoreload.start()
#tornado.autoreload.start()
tornado.ioloop.IOLoop.instance().start()