summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-02 12:45:27 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-02 12:45:27 +0100
commit1c76b686a5896950b0037e773d5229e401e980b3 (patch)
treedbb22072b0d82361546f24095a6f5be601117ecc /monkey
parent8966a1486c031478f3c9c35d9d2914a96782ae53 (diff)
Parse 'experiment' actions
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