/tsimapiak/parse.py |
---|
127,5 → 127,6 |
if word == None: |
word = parseword(sent[-left:]) |
left -= len(word["word"]["navi"].split(" ")) |
word["word"]["translated"] = dbconnector.translate(word["word"]["id"],"eng") |
ret.append(word) |
return ret |
return ret |
/tsimapiak/dbconnector.py |
---|
32,4 → 32,14 |
else: |
ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]}) |
db.close() |
return ret |
return ret |
def translate(word,language): |
db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi") |
for row in db.query(""" |
SELECT * |
FROM `localizedWords` |
WHERE id = ? AND languageCode = ?""",word,language): |
ret = row["localized"] |
db.close() |
return ret |
/webapp/templates/parse.html |
---|
1,9 → 1,9 |
{% extends "base.html" %} |
{% block title %}Word parser{% end %} |
{% block title %}Sentence parser{% end %} |
{% block body %} |
<b>Na'vi word:</b><br /> |
<b>Na'vi sentence:</b><br /> |
<form action="/parse" method="post"> |
<input id="word" name="word" type="text" value="{{last}}" style="width: 100%;" /> |
<input name="btn" type="submit" value="Parse!" /> |
12,6 → 12,7 |
<table border="1"> |
<tr> |
<th>Words</th> |
<th>English</th> |
<th>Parts</th> |
<th>Data</th> |
</tr> |
18,6 → 19,7 |
{% for wor in out %} |
<tr> |
<td rowspan="4">{{ wor["word"]["navi"] }}</td> |
<td rowspan="4">{{ wor["translated"] }}</td> |
<td>Infixes:</td> |
<td>{{ u", ".join(wor["inf"]) }}</td> |
</tr> |
36,8 → 38,8 |
{% end %} |
</table> |
{% end %} |
<p>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!</p> |
<script type="text/javascript"> |
document.getElementById("word").focus(); |
</script> |
<p>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!</p> |
{% end %} |
/webapp/static/favicon.ico |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/webapp/main.py |
---|
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,7 → 67,7 |
("/restart", Restart), |
("/testdb", TestDB), |
("/parse", Parse) |
], static_path = "static") |
], **settings) |
if __name__ == "__main__": |
http_server = tornado.httpserver.HTTPServer(application) |