Trouble getting two phrases to work optionally in same TopRule

I am trying to to test two phrases in my .rule file:

“we do not have a sweeper”
“add a goalkeeper to the team list”

The rule is the following:

TopRule = $* (
    $add{action='addToTeam'}{listType='Team'} $teamMember{teamMember=teamMember._member} $to (the) (*$team) list  |
    $we{action='addToTeam'}{listType='Team'} out of $teamMember{teamMember=teamMember._member}
) $*;

teamMember @= (+$w){_member=_parsed};

add = add | enlist;
we = we | (we are) | were;
team = roster | team;
to = to | on | in;

They work individually but when they are together in the TopRule they don’t work.

you will want to wrap the two potential phrases separated by the “|” in their own set of parenthesis. That should allow both phrases to work without the parts of the rule file you mentioned. So your code will want to be the following:

TopRule = $* (
    ($add{action='addToTeam'}{listType='Team'} $teamMember{teamMember=teamMember._member} $to (the) (*$team) list)  |
    ($we{action='addToTeam'}{listType='Team'} do not have  $teamMember{teamMember=teamMember._member})
) $*;


teamMember @= (+$w){_member=_parsed};

add = add | enlist;
we = we | (we are) | were;
team = roster | team;
to = to | on | in;
1 Like