From 5dfe53f84b000554177c69c6d8303387daf45688 Mon Sep 17 00:00:00 2001 From: "Robert L. West" Date: Thu, 23 Feb 2023 14:26:17 -0500 Subject: [PATCH] Update pattern.py --- python_actr/pattern.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/python_actr/pattern.py b/python_actr/pattern.py index da65994..c292b40 100644 --- a/python_actr/pattern.py +++ b/python_actr/pattern.py @@ -119,8 +119,18 @@ def callfunc(x,b,name=name,p=p): namedSlots=True else: if namedSlots!=False: - raise PatternException("Found unnamed slot '%s' after named slot in pattern '%s'"%(text,pattern)) - if text=='?': continue + raise PatternException("Found unnamed slot '%s' after named slot in pattern '%s'"%(text,pattern)) + # + # fixes the problem with matching to ? + # condition: wildcard value that doesn't assign a name (i.e. pattern 'chunkname:?' or just '?') + if text == '?': + # returns true if *either* x (the chunk, a UserDict) contains a key (slot name) that matches the + # name (key) of the wildcarded slot in our pattern (if there is no name, the slot is numbered, + # and key is the corresponding number) + funcs.append(lambda x, b, key=key: key in x.keys()) + continue + # + # while len(text)>0: m=re.match('([\w\.-]+)',text) #print("2m", m)#sterling