Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/switch to python3 #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ git clone git@github.com:TartuNLP/neurotolge.git
The last step is installation requirements:

```
pip install requirements.txt
pip install -r requirements.txt
```

which can be found in the project.
Expand Down
20 changes: 10 additions & 10 deletions neurotolge.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main_page(default_language=app_default_language):
@app.route("/play", methods=['GET'])
def play():
request_args = request.args
print "Play request arguments :", request_args
print("Play request arguments :", request_args)

translation_google = ''
translation_tilde = ''
Expand All @@ -80,16 +80,16 @@ def play():
translation_tilde = translations['translation_tilde']
translation_ut = translations['translation_ut']

print {"from": language_translate_from,
print({"from": language_translate_from,
"to": language_translate_to,
"source_text": source_text}
"source_text": source_text})

print {"google": translation_google,
print({"google": translation_google,
"tilde": translation_tilde,
"ut": translation_ut}
"ut": translation_ut})

except BadRequestKeyError as e:
print "BadRequestKeyError occurred: ", e.message
print("BadRequestKeyError occurred: ", e.message)

end_translation_time = time.time()
print("Total translation time : ", end_translation_time - start_translation_time)
Expand Down Expand Up @@ -121,15 +121,15 @@ def translate():
language_translate_to = request_args['to']
source_text = request_args['q']

print {"from": language_translate_from,
print({"from": language_translate_from,
"to": language_translate_to,
"source_text": source_text}
"source_text": source_text})
ut = UT(source_text, language_translate_from, language_translate_to)
ut_translation = ut.get_translation()
except BadRequestKeyError as e:
print "BadRequestKeyError occurred: ", e.message
print("BadRequestKeyError occurred: ", e.message)

print "UT translation", ut_translation
print("UT translation", ut_translation)

if ut_translation == "":
return json.dumps({
Expand Down
4 changes: 2 additions & 2 deletions parallel_translation/parallel_translation_requests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- encoding: utf-8 -*-

import Queue
import queue
import threading

from translators.google import Google
Expand All @@ -18,7 +18,7 @@ def start_thread(object):


def get_translations(source_text, language_translate_from, language_translate_to, timeout=3, num_translators=3):
queue = Queue.Queue()
queue = queue.Queue()
print("get_translations : language_translate_from", language_translate_from)
print("get_translations : language_translate_to", language_translate_to)

Expand Down
2 changes: 1 addition & 1 deletion translators/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import time
import datetime
from abstract_translator import AbstractTranslator
from .abstract_translator import AbstractTranslator


class Google(AbstractTranslator):
Expand Down
3 changes: 1 addition & 2 deletions translators/tilde.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import time
import datetime
from abstract_translator import AbstractTranslator

from .abstract_translator import AbstractTranslator

class Tilde(AbstractTranslator):
class ValidationError(Exception):
Expand Down
6 changes: 3 additions & 3 deletions translators/ut.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import time
import datetime
from abstract_translator import AbstractTranslator
from .abstract_translator import AbstractTranslator


class UT(AbstractTranslator):
def __init__(self, source_text, translate_from, translate_to, queue):
def __init__(self, source_text, translate_from, translate_to, queue=None):
AbstractTranslator.__init__(self, source_text, translate_from, translate_to, queue)
self.translation_object = {}

Expand Down Expand Up @@ -48,6 +48,6 @@ def get_translation_object(self):
try:
self._external_api_integration()
except Exception as e:
print e.message
print(e.message)

return self.translation_object