diff options
author | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-30 16:00:12 -0700 |
---|---|---|
committer | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-30 16:00:12 -0700 |
commit | 3cc87778e8985ff7e1bcf3a4a12d071c2ddd5639 (patch) | |
tree | c860fbdf22c1ef0b26a8b244af9453db0c8b920e /realtime/rt/decoder.py | |
parent | 046e726aa598c75ca8f5a22a74d83cd2c405b741 (diff) |
New commands, save/load context
Diffstat (limited to 'realtime/rt/decoder.py')
-rw-r--r-- | realtime/rt/decoder.py | 12 |
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''' |