summaryrefslogtreecommitdiff
path: root/realtime/rt/decoder.py
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-30 16:00:12 -0700
committerMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-30 16:00:12 -0700
commitbf3b6d31e7402252188ecb814a8fcdfd755c10ac (patch)
tree37eca89eab204c01b40b8c407112a80d0a7bdec8 /realtime/rt/decoder.py
parente97bb01cc3a0790dc8dc474db2fd204cbd3fe579 (diff)
New commands, save/load context
Diffstat (limited to 'realtime/rt/decoder.py')
-rw-r--r--realtime/rt/decoder.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/realtime/rt/decoder.py b/realtime/rt/decoder.py
index da646f68..15f7db3f 100644
--- a/realtime/rt/decoder.py
+++ b/realtime/rt/decoder.py
@@ -55,8 +55,16 @@ class MIRADecoder(Decoder):
def set_weights(self, w_line):
'''Threadsafe, FIFO'''
self.lock.acquire()
- self.decoder.stdin.write('WEIGHTS ||| {}\n'.format(w_line))
- self.lock.release()
+ try:
+ # Check validity
+ for w_str in w_line.split():
+ (k, v) = w_str.split('=')
+ float(v)
+ self.decoder.stdin.write('WEIGHTS ||| {}\n'.format(w_line))
+ self.lock.release()
+ except:
+ raise Exception('Invalid weights line: {}'.format(w_line))
+
def update(self, sentence, grammar, reference):
'''Threadsafe, FIFO'''