-
Notifications
You must be signed in to change notification settings - Fork 5
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
Action rule syntax #54
Comments
Give #63 I feel that the usage of the equals sign in more of a problem because the rest of the action rule language ends up being much closer to normal Python. To me a syntax like
seems much better (potentially even allowing both directions of the arrow) as it highlights more the graph structure and direction of information transmition. However, that requires to change the syntax of the basal ganglia utility value (currently using Tagging @astoeckel (who initially brought this issue up, I believe) and tagging @tcstewar who's opinion is always welcome in SPA questions. |
I really have no idea on this one... :( But I do like the idea of shaking up the syntax a bit. The current I wonder if we could also bring in some indenting to help with this? And also to help with complex action rules starting to become unreadable? I'm thinking something like this: Current approach: actions = spa.Actions([
'dot(vision, WRITE+SAY) --> verb=vision',
'dot(vision, YES+NO+HI+BYE+OK) --> noun=vision',
'dot(phrase, VERB*WRITE) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK)'
'--> hand=phrase*~NOUN',
'dot(phrase, VERB*SAY) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK)'
'--> speech=phrase*~NOUN',
'phrase = verb*VERB + noun*NOUN',
]) Alternate approach: actions = spa.Actions('''
dot(vision, WRITE + SAY):
verb <- vision
dot(vision, YES+NO+HI+BYE+OK):
noun <- vision
dot(phrase, VERB*WRITE) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
hand <- phrase*~NOUN
dot(phrase, VERB*SAY) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
speech <- phrase*~NOUN
phrase <- verb*VERB + noun*NOUN
''') Hmm, now that I write that out, I kinda like it... I very much like having the |
Interesting idea! What do you think should happen if someone nests the utility statements?
|
Hmm.... too many options for what that could mean, I think, so I'm tempted to just say that no, it's not allowed.... |
I think I would add a “keyword” to make it a bit more pythonic: actions = spa.Actions('''
utility dot(vision, WRITE + SAY):
verb <- vision
utility dot(vision, YES+NO+HI+BYE+OK):
noun <- vision
utility dot(phrase, VERB*WRITE) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
hand <- phrase*~NOUN
utility dot(phrase, VERB*SAY) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
speech <- phrase*~NOUN
phrase <- verb*VERB + noun*NOUN
''') Maybe even be more explicit about cortical rules (this could be optional): actions = spa.Actions('''
utility dot(vision, WRITE + SAY):
verb <- vision
always:
phrase <- verb*VERB + noun*NOUN
''') I think I would also like to include the naming of rules into that syntax. Maybe something like: actions = spa.Actions('''
utility dot(vision, WRITE + SAY) named 'vision-rule':
verb <- vision
always 'cortical-connection':
phrase <- verb*VERB + noun*NOUN
''') |
Hmm... I'm not sure that ends up being more pythonic... it just ends up looking like visual clutter to me... maybe something shorter like
I was also tempted to put in exactly that
I'd stick with the Python |
Everyline in Python that ends with a colon will start with a keyword (only exception dictionary definitions). Without a keyword it look to me like an evaluation that isn't used or assigned to anything, it might make parsing harder (the parser would have to look for colons at the end of the line, but colons might appear at the end of the line for other reasons).
I could see that ... but |
A keyword could also allow us to more easily add other types of actions in the future. |
True. I think what I meant to say is that I don't find it more usefully pythonic to have that keyword there. Or at least I don't feel like anything is missing there. After all, the
What other reasons are you thinking of? I can't think of any way that there could be a
Looking at all of those options, I think I'm most worried about the naming conflict possibilities. All of those are reasonable names for
I think that's going to far down the black-magic route, and trying to tie it too closely to Python. I was just saying that |
Why not? With pythonic I doesn't mean that it is something that currently exists in Python (because obviously we are extending the language), but something that follows common prinicples in Python.
We're using Python Actually, there might be good reasons to use spa.Action('''
if model_variant_a:
a <- b
else:
a <- c
for selector, source in zip([A, B, C], [a, b, c]):
utility dot(stimulus, selector):
state <- source
''') Not sure how easy it would be to make this work and whether it is a good idea ... |
We have the same problem with the “built-ins” ( |
Possibly. I just feel that "not having a keyword in front of a statement ending in a colon" is better than "adding a keyword that must be typed at the beginning of every action line and might conflict with existing objects". But, that's starting to get into very subjective territory, and I don't particularly trust my own judgement on these things and would want to see how other people feel. :)
All the more reason to keep these to a minimum. And it does help a lot that |
I had |
Just to add my two cents: I agree that having So I'd propose something more along these lines, though I'm not 100% sure whether this is practical: ismax dot(vision, WRITE + SAY):
verb <- vision
ismax dot(vision, YES+NO+HI+BYE+OK):
noun <- vision
ismax dot(phrase, VERB*WRITE) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
hand <- phrase*~NOUN
ismax dot(phrase, VERB*SAY) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
speech <- phrase*~NOUN
otherwise:
phrase <- verb*VERB + noun*NOUN |
Interesting... I like the idea of indicating the operation here... (one minor error: that last one should be |
Here's another option, which might be getting a bit crazy: ifmax dot(vision, WRITE + SAY):
verb <- vision
elifmax dot(vision, YES+NO+HI+BYE+OK):
noun <- vision
elifmax dot(phrase, VERB*WRITE) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
hand <- phrase*~NOUN
elifmax dot(phrase, VERB*SAY) - 2*dot(vision, WRITE+SAY+YES+NO+HI+BYE+OK):
speech <- phrase*~NOUN
always:
phrase <- verb*VERB + noun*NOUN (the reason for doing the |
I actually like the |
Okay, that is disturbingly beautiful... I hadn't thought of that at all.... :) Hmm... so I guess it ends up being one of those "find the colon at the end of a line that is outside of any nested parentheses, brackets, or braces" algorithms.... which I think would work.... The only non-line-ending colon that's not nested like that that I can think of is the colon for a ifmax dot(state, DOG)*(lambda x:
x**2)(0.5)):
state <- CAT |
I'm not going to get too involved in this thread but here are some things to consider: The I'm not entirely a fan of |
I agree. I would also be fine with supporting both variants. |
The old def action_a(state='A'):
state='B' rather than: ifmax dot(state, A):
state <- B (and then doing a bunch of Python black magic to make all that work). The Anyway, that was the main reason for me to step away from the old For me, the two biggest goals for this new system would be:
speed = 0.3
separation = 0.3
strength = 0.4
actions = spa.Actions(
'dot(rule, (BELOW-ABOVE-LEFT-RIGHT)*V)*{strength} +'
'(subjy - objy)+{separation} --> '
'status=BAD, '
'objs=-{speed}*Y*objs*~S + {speed}*Y*objs*~O'.format(**locals()),
'dot(rule, (BELOW-ABOVE-LEFT-RIGHT)*V)*{strength} +'
'(subjy - objy)-{separation} --> '
'status=GOOD'.format(**locals()),
) My hope is that could be made a bit nicer, turning into something like: speed = 0.3
separation = 0.3
strength = 0.4
actions = spa.Actions('''
ifmax dot(rule, (BELOW-ABOVE-LEFT-RIGHT)*V)*strength +
(subjy - objy)+separation:
status <- BAD
objs <- -speed*Y*objs*~S + speed*Y*objs*~O
ifmax dot(rule, (BELOW-ABOVE-LEFT-RIGHT)*V)*strength +
(subjy - objy)-separation:
status <- GOOD
''') I didn't think that it'd be at all possible to have those local variables accessible in the parsing until @jgosmann came up with this "inspective parsing" approach.... To me that lets us adjust the syntax in some interesting ways, while still keeping access to normal python variables and whatnot. Anyway, not sure if all that helps, but it's what I'm thinking about this at the moment. :) |
I spent some time on writing a tokenizer/lexer for the new action rule syntax, rewriting my partial solution once to improve it, and still ending up dissatisfied. Now I discovered the standard library module While playing around, I noticed that |
Actually most arrow-like constructs are already Python operators in at least one direction: |
It was noted during the last lab meeting that the current action rule syntax might be misleading with its use of the equals sign. Currently, action rules use this syntax:
utility --> sink = source
. Please use this issue to suggest alternatives to the-->
and=
symbols.The text was updated successfully, but these errors were encountered: