Skip to content

Update pattern.py #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions python_actr/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down