/tsimapiak/parsenum.py |
---|
12,6 → 12,15 |
u"pukap", |
u"kinä"] |
numord = [u"kewve", |
u"'awve", |
u"muve", |
u"pxeyve", |
u"tsìve", |
u"mrrve", |
u"puve", |
u"kive"] |
rem = [u"aw", |
u"mun", |
u"pey", |
20,6 → 29,14 |
u"fu", |
u"hin"] |
remord = [u"awve", |
u"muve", |
u"peyve", |
u"sìve", |
u"mrrve", |
u"fuve", |
u"hive"] |
base = [u"", |
u"me", |
u"pxe", |
30,21 → 47,21 |
numre = \ |
u"^(a?)(?:(" + "|".join(base) + u")zazam??)?" + \ |
u"(?:(" + "|".join(base) + u")vozam??)?" + \ |
u"(?:(" + "|".join(base) + u")zam??)?" + \ |
u"(?:(" + "|".join(base) + u")vo(?:l(?=a|))?)?" + \ |
u"((?:" + "|".join(rem) + u")|" + \ |
u"(?:" + "|".join(num) + u"))?((?:ve)?)(a?)$" |
u"^(a?)(?:(?:(" + "|".join(base) + u")zaza(?=m)(?:ve(?=$))?)?" + \ |
u"(?:(" + "|".join(base) + u")voza(?=m)(?:ve(?=$))?)?" + \ |
u"(?:(" + "|".join(base) + u")za(?=m)(?:ve(?=$))?)?" + \ |
u"(?:(" + "|".join(base) + u")(?:vol|vo(?=a|$))(?:ve(?=$))?)?" + \ |
u"(?:" + "|".join(remord + rem) + u"))|" + \ |
u"(?:" + "|".join(numord + num) + u")?(a?)$" |
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: |
/tsimapiak/parse.py |
---|
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<npr>(?:(?:fì|tsa)?(?:me|pxe|ay|fra)?|(?:fay)?|(?:tsay)?)(?:fne)?(?:tì|sä)?" |
#prefixesv = ur"(?P<vpr>(?:nì|sä|tì|rä'ä |ke )?)" |
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 |
/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 |
/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/parse.html |
=================================================================== |
--- webapp/templates/parse.html (revision 117) |
+++ webapp/templates/parse.html (revision 133) |
@@ -1,9 +1,9 @@ |
{% extends "base.html" %} |
-{% block title %}Word parser{% end %} |
+{% block title %}Sentence parser{% end %} |
{% block body %} |
-Na'vi word: |
+Na'vi sentence: |
@@ -36,8 +36,8 @@ |
{% end %} |
This program uses Eana Eltu for the list of words and infix positions (but nothing else), created by Tuiq and Taronyu. Thanks also go to the rest of the Learn Na'vi community!
This program uses Eana Eltu for the list of words and infix positions (but nothing else), created by Tuiq and Taronyu. Thanks also go to the rest of the Learn Na'vi community!
/webapp/templates/base.html |
---|
1,6 → 1,7 |
<html> |
<head> |
<title>Tsim Apiak - {% block title %}Title{% end %}</title> |
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" /> |
<style type="text/css"> |
body { |
background: #145179; |
/webapp/templates/index.html |
---|
0,0 → 1,8 |
{% extends "base.html" %} |
{% block title %}Home{% end %} |
{% block body %} |
<a href="/number"><b>Number translator</b></a> - this webapp allows you to translate written-out Na'vi numbers into decimal and octal.<br /> |
<a href="/parse"><b>Parser</b></a> - 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 %} |
/webapp/templates/number.html |
---|
17,4 → 17,4 |
<script type="text/javascript"> |
document.getElementById("num").focus(); |
</script> |
{% end %} |
{% end %} |
/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): |
57,6 → 57,10 |
out = parse.parsesent(word) |
self.render("templates/parse.html", last=word, out=out) |
settings = { |
"static_path": os.path.join(os.path.dirname(__file__), "static") |
} |
application = tornado.web.Application([ |
("/", Index), |
("/number", Number), |
63,10 → 67,10 |
("/restart", Restart), |
("/testdb", TestDB), |
("/parse", Parse) |
]) |
], **settings) |
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() |