/webapp/main.py |
---|
15,7 → 15,7 |
class Index(tornado.web.RequestHandler): |
def get(self): |
self.redirect("/number") |
self.render("templates/index.html") |
class Number(tornado.web.RequestHandler): |
def get(self): |
63,10 → 63,10 |
("/restart", Restart), |
("/testdb", TestDB), |
("/parse", Parse) |
]) |
], settings = {"static_path": "static"}) |
if __name__ == "__main__": |
http_server = tornado.httpserver.HTTPServer(application) |
http_server.listen(1337) |
#tornado.autoreload.start() |
tornado.ioloop.IOLoop.instance().start() |
tornado.ioloop.IOLoop.instance().start() |
/webapp/static/favicon.ico |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/webapp/static/favicon.ico |
---|
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+application/octet-stream |
\ No newline at end of property |
Index: webapp/templates/index.html |
=================================================================== |
--- webapp/templates/index.html (nonexistent) |
+++ webapp/templates/index.html (revision 129) |
@@ -0,0 +1,8 @@ |
+{% extends "base.html" %} |
+ |
+{% block title %}Home{% end %} |
+ |
+{% block body %} |
+Number translator - this webapp allows you to translate written-out Na'vi numbers into decimal and octal. |
+Parser - this webapp can parse Na'vi sentences into the base words, prefixes, infixes and suffixes. It does not currently translate the words, but that will come. |
+{% end %} |
Index: webapp/templates/number.html |
=================================================================== |
--- webapp/templates/number.html (revision 117) |
+++ webapp/templates/number.html (revision 129) |
@@ -17,4 +17,4 @@ |
document.getElementById("num").focus(); |
-{% end %} |
+{% end %} |
\ No newline at end of file |
Index: tsimapiak/parse.py |
=================================================================== |
--- tsimapiak/parse.py (revision 117) |
+++ tsimapiak/parse.py (revision 129) |
@@ -12,7 +12,7 @@ |
infixes3 = (u"äng", u"ats", u"eiy", u"ei", u"uy", u"") |
prefixes = (u"tsay", u"fay", u"fra", u"pxe", u"fne", u"tsa", u"pe", u"le", u"nì", u"sä", u"tì", u"ay", u"me", u"fì", u"ke", u"a") |
adpositions = (u"mungwrr", u"kxamlä", u"pximaw", u"pxisre", u"tafkip", u"nemfa", u"takip", u"mìkam", u"teri", u"fkip", u"luke", u"pxel", u"pxaw", u"rofa", u"ìla", u"fpi", u"ftu", u"kip", u"lok", u"maw", u"sre", u"sìn", u"vay", u"eo", u"fa", u"hu", u"io", u"ka", u"mì", u"na", u"ne", u"ro", u"ta", u"uo", u"wä", u"äo", u"to") |
-postfixes = adpositions + (u"tsyìp", u"eyä", u"ìri", u"ìl", u"it", u"lo", u"ri", u"ru", u"ti", u"ur", u"ve", u"yä", u"ya", u"tu", u"vi", u"yu", u"an", u"ng", u"e", u"o", u"l", u"t", u"y", u"a", u"ä", u"r") |
+postfixes = adpositions + (u"tsyìp", u"eyä", u"ìri", u"ìl", u"it", u"lo", u"ri", u"ru", u"ti", u"ur", u"ve", u"yä", u"ya", u"tu", u"vi", u"yu", u"an", u"ng", u"ke", u"e", u"o", u"l", u"t", u"y", u"a", u"ä", u"r") |
#prefixesn = ur"(?P |
#prefixesv = ur"(?P |
@@ -76,19 +76,31 @@ |
foundit = False |
break |
pref, posf = temp |
- for pre in prefixes: |
- if pref != u"": |
- if pref.endswith(pre): |
- foundprefs[wor].append(pre) |
- pref = pref[:-len(pre)] |
+ last = u"" |
+ while last != pref: |
+ last = pref |
+ for pre in prefixes: |
+ if pref != u"": |
+ if pref.endswith(pre): |
+ if pre in foundprefs[wor]: |
+ break |
+ foundprefs[wor].append(pre) |
+ pref = pref[:-len(pre)] |
+ break |
if pref != u"": |
foundit = False |
break |
- for pos in postfixes: |
- if posf != u"": |
- if posf.startswith(pos): |
- foundposts[wor].append(pos) |
- posf = posf[len(pos):] |
+ last = u"" |
+ while last != posf: |
+ last = posf |
+ for pos in postfixes: |
+ if posf != u"": |
+ if posf.startswith(pos): |
+ if pos in foundposts[wor]: |
+ break |
+ foundposts[wor].append(pos) |
+ posf = posf[len(pos):] |
+ break |
if posf != u"": |
foundit = False |
break |
@@ -116,4 +128,4 @@ |
word = parseword(sent[-left:]) |
left -= len(word["word"]["navi"].split(" ")) |
ret.append(word) |
- return ret |
+ return ret |
\ No newline at end of file |
/tsimapiak/dbconnector.py |
---|
32,18 → 32,4 |
else: |
ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]}) |
db.close() |
return ret |
#def gettrans(id, cod): |
#ret = [] |
#if cod not in (u"est",u"ptbr",u"de",u"eng",u"all"): |
#return ret |
#db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
#if cod == "all": |
#for row in db.query(""" |
#SELECT * |
#FROM `metaWords` |
#WHERE id = ?""",idd): |
#infix = makeinfix(row) |
#ret.append([row["id"],row["navi"], infix, row["partOfSpeech"]]) |
#db.close() |
return ret |
/tsimapiak/parsenum.py |
---|
39,12 → 39,12 |
numre = re.compile(numre) |
def parse(numin): |
if numin in (u"a", u"aa", u"ave", u"avea", u"ve", u"vea"): |
return None |
try: |
mat = numre.match(numin).groups() |
except: |
return None |
if mat[5] == u"" and mat[4] == u"" and mat[3] == u"" and mat[2] == u"" and mat[1] == u"": |
return None |
numout = 0 |
numoct = 0 |
try: |