/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/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/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/main.py |
=================================================================== |
--- webapp/main.py (revision 122) |
+++ webapp/main.py (revision 136) |
@@ -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) |
-]) |
+], **settings) |
if __name__ == "__main__": |
http_server = tornado.httpserver.HTTPServer(application) |