diff --git a/folia/fql.py b/folia/fql.py index 9d74352..dceb8bb 100644 --- a/folia/fql.py +++ b/folia/fql.py @@ -1262,7 +1262,7 @@ def substitute(self, query, substitution, contextselector, debug): kwargs = self.assemblesuggestions(query,substitution,debug,kwargs) - if debug: print("[FQL EVALUATION DEBUG] Correction.substitute - Applying and returning correction",file=sys.stderr) + if debug: print("[FQL EVALUATION DEBUG] Correction.substitute - Applying and returning correction with keyword arguments:", repr(kwargs),file=sys.stderr) return substitution['parent'].correct(**kwargs) @@ -1278,6 +1278,10 @@ def assemblesuggestions(self, query, substitution, debug, kwargs): except KeyError: actionassignments['set'] = query.doc.defaultset(Class) actionassignments['id'] = "corrected.%08x" % random.getrandbits(32) #generate a random ID + if 'textclass' in actionassignments: + #FQL uses text class differently (to set) than the folia library's textclass property (for provenance) + actionassignments['settextclass'] = actionassignments['textclass'] + del actionassignments['textclass'] e = Class(query.doc, **actionassignments) if debug: print("[FQL EVALUATION DEBUG] Correction.assemblesuggestions - Adding to new",file=sys.stderr) kwargs['new'].append(e) @@ -1674,10 +1678,11 @@ def __call__(self, query, contextselector, debug=False): if debug: print("[FQL EVALUATION DEBUG] Action - setphon("+ value+ ") on focus ", repr(focus),file=sys.stderr) focus.setphon(value) else: - if debug: print("[FQL EVALUATION DEBUG] Action - settext("+ value+ ") on focus ", repr(focus),file=sys.stderr) if attr == 'text' and 'textclass' in action.assignments: + if debug: print("[FQL EVALUATION DEBUG] Action - settext("+ value+ ",cls=" + action.assignments['textclass'] + ") on focus ", repr(focus),file=sys.stderr) focus.settext(value, action.assignments['textclass']) else: + if debug: print("[FQL EVALUATION DEBUG] Action - settext("+ value+ ") on focus ", repr(focus),file=sys.stderr) focus.settext(value) elif attr == "class": if debug: print("[FQL EVALUATION DEBUG] Action - " + attr + " = " + value + " on focus ", repr(focus),file=sys.stderr) @@ -1870,6 +1875,7 @@ def __call__(self, query, contextselector, debug=False): constrainedtargetselection_all = [] constrainedtargetselection = [] if action.form: + if debug: print("[FQL EVALUATION DEBUG] Form - Invoking Subtitution through Form (" + repr(action.form)+")",file=sys.stderr) result = action.form.substitute(query, substitution, None, debug) if len(actions) > 1: focusselection_all.append(result) diff --git a/folia/main.py b/folia/main.py index 70da512..bfd9fa2 100644 --- a/folia/main.py +++ b/folia/main.py @@ -974,7 +974,11 @@ def parsecommonarguments(self, doc, **kwargs): if 'text' in kwargs: if kwargs['text']: - self.settext(kwargs['text']) + if 'settextclass' in kwargs: + self.settext(kwargs['text'], kwargs['settextclass']) + del kwargs['settextclass'] + else: + self.settext(kwargs['text']) del kwargs['text'] if 'phon' in kwargs: