From c60dd8c66eb330a687fbd541f61663e185df53e0 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 3 Mar 2015 10:20:44 +0100 Subject: =?UTF-8?q?Ignore=20edits=20a=E2=86=92b=20where=20a=20or=20b=20has?= =?UTF-8?q?=20multiple=20parts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- monkey/edits.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'monkey') 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)) -- cgit v1.2.1