|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
Is there any way to use variables with reuse()?
I’m currently using reuse($rule) and saving labels like $rule = LABEL but thats a bit annoying. I tried creating a single letter outputmacro r $rule = %rule but nothing is saved in the variable.
Does %rule save the topic as well so it can be called from other topics?
|
|
|
|
|
Posted: Dec 20, 2015 |
[ # 1 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
^reuse DOES evaluate its argument, so it should work fine with a $var argument.
%rule generates a complete tag, including topic name.
Since you are sloppy in writing your text here, I cannot say whether you are doing it correctly in your code.
outputmacro r $rule = %rule is not legal syntax
outputmacro: ^r() $rule = %rule is legal.
And a reference in text to it would be
u: () this is my ^r() output
|
|
|
|
|
Posted: Dec 20, 2015 |
[ # 2 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
I didnt notice I had a leading space before the parens so it prolly wasnt defined. Thanks.
Btw, Bruce, is there a quick way/system command to test if a pattern matches a string?
|
|
|
|
|
Posted: Dec 21, 2015 |
[ # 3 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
What does it mean that a pattern matches a string. Give an example of what you seek?
|
|
|
|
|
Posted: Dec 21, 2015 |
[ # 4 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
is there sysfunc like
:match (~psychology_adjectives * role_romantic) “I’m depressed about my wife”
Wait there is testpattern right? I think I recall that supports custom concepts and variables as well?
|
|
|
|
|
Posted: Dec 21, 2015 |
[ # 5 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
There are two things:
:testpattern (pattern data ) sample input
^match(pattern data)——operating on current input.
|
|
|
|
|
Posted: Dec 21, 2015 |
[ # 6 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
Thanks.
^respond currently matches a sentences with a topic pattern and executes the rule. Can I just match it so I can go do something else when I know there is a match?
|
|
|
|
|
Posted: Dec 21, 2015 |
[ # 7 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
can I use the second FAIL argument? I THINK so.
So to make use of that I suppose I could loop through topics returned by ^gambittopics. Is there any function that returns the names of all topics? even ones with just responders remaining?
|
|
|
|
|
Posted: Dec 22, 2015 |
[ # 8 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
if you want the names of all topics, do a query(direct_v ? member ?) and then prove each answer has the topic flag bit
|
|
|
|
|
Posted: Dec 22, 2015 |
[ # 9 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
Sorry not sure I understand that.
query(direct_v ? member ?) would return a HUGE svo factlist of all concepts right?
What do you mean by prove each “answer”? Would I be checking the subject or the object? Since the name is defined in the subject, I assume I would check the object.
I also cant find any info on the topic flag bit. Is it defined in ~sys? How is it specified? ~topic?
|
|
|
|
|
Posted: Dec 22, 2015 |
[ # 10 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
OK. not practical, I agree. Why did you want a list of all topics instead of just ones your sentence has keywords of?
|
|
|
|
|
Posted: Dec 22, 2015 |
[ # 11 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
As for ^substitute, you can use the optional 5th argument to tell it to indicate failure. Although I will probably directly support ~email_url in the engine in the next release.
|
|
|
|
|
Posted: Dec 22, 2015 |
[ # 12 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
I just want a topic listing because ^respond looks in specific topics for matching rules to the current sentence. I suppose I could manually specify each topic name but I just wanted to know if there was another way to find rules in ALL topics to match with input without executing the rue.
Btw, I doubt your last post about ^substitute was meant for THIS thread.
|
|
|
|
|
Posted: Dec 23, 2015 |
[ # 13 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
Also I suppose I could create a table of my topics and loop through that with if (^respond($topic FAIL) == FAILRULE_BIT) {Found matching rule in $topic}
Would that work for what I want?
Also say I found a matching rule using ^respond($topic fail) is there any way to save the rule so I can go output something else say in a t: ($undef) gambit with rejoinders and then respond with the saved rule in a matching rejoinder in the gambit?
|
|
|
|
|
Posted: Dec 23, 2015 |
[ # 14 ]
|
|
Senior member
Total posts: 136
Joined: Jun 20, 2014
|
I suppose that would involve another statement in the control script like
u: RULEMATCH ($rulematch==true) Output sentence
a:(pattern1) Output then set $rulematch = false then execute previous matched rule
a:(patern1) Output then set $rulematch = false then execute previous matched rule
that is activated by $rulematch = true then reuse(RULEMATCH) in the harry u:() if a matching rule is found but not sure how to save the previous matching rule to respond with it in u:($rulematch==true) rejoinders since using %rule in the u() in the control script would when, ^respond($topic FAIL) matches a rule, would only match u:()
|
|
|
|
|
Posted: Dec 24, 2015 |
[ # 15 ]
|
|
Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
^respond currently matches a sentences with a topic pattern and executes the rule. Can I just match it so I can go do something else when I know there is a match?
technically you can. You can write a script that retrieves the pattern components of the rules of a topic, tries them, and notes if they match, and saves the topic tag so it could be executed later.
|
|
|
|