summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/action.py18
1 files 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