summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-03-03 10:20:44 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:02 +0200
commitc60dd8c66eb330a687fbd541f61663e185df53e0 (patch)
tree0cc6b3ac5339954d1a9d01a05a30777acb2069c9 /monkey
parenta60b0ef82a3f6c0cc38084200f92ae293d729116 (diff)
Ignore edits a→b where a or b has multiple parts
This happens for instance when a user writes more than one goal on the same line. A better way would be to handle this when building a graph (use annotate instead of splitting on newlines).
Diffstat (limited to 'monkey')
-rw-r--r--monkey/edits.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/monkey/edits.py b/monkey/edits.py
index 8b8c3c3..fc95e8b 100644
--- a/monkey/edits.py
+++ b/monkey/edits.py
@@ -5,7 +5,7 @@ import math
from .action import expand, parse
from .graph import Node
-from prolog.util import normalized, rename_vars, stringify, tokenize
+from prolog.util import annotate, normalized, rename_vars, stringify, tokenize
from .util import get_line, avg, logistic
# Parse the sequence of actions in [trace] and return a directed acyclic graph
@@ -149,12 +149,16 @@ def graph_edits(nodes):
if start == end:
continue
+ # An edit start → ε happens each time the user inserts \n; ignore
+ # such cases.
if not end and len(a.eout) > 1:
continue
- # Disallow edits that insert a whole rule (a → …:-…).
- # TODO improve trace_graph to handle this.
- if 'FROM' in [t.type for t in end[:-1]]:
+ # Skip edits where start/end is composed of more than one part.
+ # TODO improve trace_graph to handle this instead.
+ if [t for t in annotate(stringify(start)) if t.part > 0]:
+ continue
+ if [t for t in annotate(stringify(end)) if t.part > 0]:
continue
edits.add((start, end))