From 1c76b686a5896950b0037e773d5229e401e980b3 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 2 Mar 2016 12:45:27 +0100 Subject: Parse 'experiment' actions --- monkey/action.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/monkey/action.py b/monkey/action.py index 43747b0..c2f73ad 100644 --- a/monkey/action.py +++ b/monkey/action.py @@ -67,6 +67,8 @@ class Action: # obsolete Prolog "solve all" action self.type = 'prolog_solve' self.query = data['qry'] + elif self.type == 'experiment': + self.data = data['data'] # Python actions elif self.type == 'python_input': @@ -81,19 +83,21 @@ class Action: def __str__(self): s = 't = ' + str(self.time/1000.0) + ' ' + self.type if self.type in {'insert', 'remove'}: - s += ' "' + self.text.replace('\n', '\\n').replace('\t', '\\t') + '" at ' + str(self.offset) + s += ': "' + self.text.replace('\n', '\\n').replace('\t', '\\t') + '" at ' + str(self.offset) elif self.type == 'test': - s += ' {0} / {1}'.format(self.n_correct, self.n_all) + s += ': {0} / {1}'.format(self.n_correct, self.n_all) elif self.type == 'hint': if self.feedback is not None: - s += ' ' + ', '.join(sorted([hint['id'] for hint in self.feedback])) + s += ': ' + ', '.join(sorted([hint['id'] for hint in self.feedback])) else: - s += ' ?' + s += ': ?' elif self.type == 'plan': if self.index is not None: - s += ' ' + str(self.index) + s += ': ' + str(self.index) elif self.type == 'prolog_solve': - s += ' "' + self.query + '"' + s += ': "' + self.query + '"' + elif self.type == 'experiment': + s += ': ' + self.data; return s # apply this action to text @@ -131,7 +135,7 @@ def parse(data): action = Action(time, packet) except: # ignore any errors while decoding a packet - sys.stderr.write('Error decoding packet: {}'.format(packet)) + sys.stderr.write('Error decoding packet: {}\n'.format(packet)) continue # skip normalization if this is the first action -- cgit v1.2.1