summaryrefslogtreecommitdiff
path: root/realtime/rt/rt.py
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-15 20:32:59 -0700
committerMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-15 20:32:59 -0700
commit895dfd64ea5599ab16981cbfb538ec5f4073c8c1 (patch)
tree969ded641a86f3cc9ba07685b5bfccd7a50d9a8c /realtime/rt/rt.py
parent58763340c02ddafa056d0a00a061cecfb33c9c0c (diff)
Move to using named commands
Diffstat (limited to 'realtime/rt/rt.py')
-rw-r--r--realtime/rt/rt.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/realtime/rt/rt.py b/realtime/rt/rt.py
index 1b8ac58c..0ce05a56 100644
--- a/realtime/rt/rt.py
+++ b/realtime/rt/rt.py
@@ -19,6 +19,8 @@ class RealtimeDecoder:
def __init__(self, configdir, tmpdir='/tmp', cache_size=5, norm=False):
+ self.commands = {'LEARN': self.learn}
+
cdec_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Temporary work dir
@@ -126,6 +128,12 @@ class RealtimeDecoder:
self.detokenizer.stdin.write('{}\n'.format(line))
return self.detokenizer.stdout.readline().strip()
+ def command(self, args):
+ try:
+ self.commands[args[0]](*args[1:])
+ except:
+ logging.info('Command error: {}'.format(' ||| '.join(args)))
+
def learn(self, source, target):
if '' in (source.strip(), target.strip()):
logging.info('Error empty source or target: {} ||| {}'.format(source, target))