diff options
-rw-r--r-- | monkey/edits.py | 12 |
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)) |