possible to run script after match question|watcher60|watcher60@gmail.com|1322179251|watcher60|xx|0|90.202.97.251|Hi,<br /> &nbsp;is it feasible to run a script that would generate information that would then be used in the reply. However it would first match the question based upon the pattern matching answer&gt;response files.<br /><br />As an example this is the flow I'm looking to write.<br /><br />User asks &quot;how many sides does a triangle have?&quot;<br />Bot first identifies the type of question as a fact request for triangle<br />This launches a script that checks its brain file for triangle &amp; sides.<br /> If it does not have any information on this then launches a web search and tries to find the fact (eg &quot;triangles have&quot;+sides) and searches the result for /triangles have [0-9]+ sides/.<br /> If it suceeds writes the fact to its brain file for triangles (eg 3 sides) and responds &quot;traingles have 3 sides&quot; <br /><br />Thanks in advance Matt||||
Re: possible to run script after match question|Kirsle|casey@cuvou.net|1322179766|Kirsle|xx|0|68.41.61.125|Would something like this work?<br /><br />[code]+ how many sides does a * have<br />- &lt;call&gt;findsides &lt;star&gt;&lt;/call&gt;<br /><br />&gt; object findsides perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; my $shape = $args-&gt;[0]; # &quot;triangle&quot;<br /><br /> &nbsp; # do w/e you need to do<br /> &nbsp; return &quot;A $shape has $sides&#123;$shape&#125; sides.&quot;;<br />&lt; object[/code]<br /><br />The chatbot &quot;Libby&quot; from [url]http://purpletree.org/[/url] does what you describe.. if it doesn't know the answer to a question, it googles it and remembers what it found in case you ask it again in the future. It uses RiveScript to organize its brain, but I'm not sure exactly how it works besides that.||||
Re: possible to run script after match question|watcher60|watcher60@gmail.com|1322180195|watcher60|xx|0|90.202.97.251|thats great - I'll have a dig to see what code I murder...I mean write :)<br /><br />many thanks for the quick reply!||||
Re: possible to run script after match question|watcher60|watcher60@gmail.com|1322220288|watcher60|xx|0|90.202.97.251|I realise not the forum to be learning perl (and I promise I'll leave this as the last Q!) but could  you explain your example to code to me.<br /><br />To test I tried your code snippet &nbsp;in the logic.rs file.<br /><br />Even when removing any passing of varibles per the below I get the ERR Object not found msg - am I missing something obvious .<br /><br /><br />[code]+ how many sides does a * have<br />- &lt;call&gt;findsides &lt;star&gt;&lt;/call&gt;<br /><br />&gt; object findsides perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; my $shape = triangle<br /> &nbsp; my $sides = 3<br /> &nbsp; <br /> &nbsp; return &quot;A $shape has $sides sides.&quot;;<br />&lt; object <br />[/code]<br /><br /><br />||1322227124|watcher60|
Re: possible to run script after match question|Kirsle|casey@cuvou.net|1322233276|Kirsle|xx|0|68.41.61.125|[code]+ how many sides does a * have<br />- &lt;call&gt;findsides &lt;star&gt;&lt;/call&gt;<br /><br />&gt; object findsides perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; my $shape = &quot;triangle&quot;;<br /> &nbsp; my $sides = 3;<br /><br /> &nbsp; return &quot;A $shape has $sides sides.&quot;;<br />&lt; object[/code]<br /><br />That should do it.||||
Re: possible to run script after match question|watcher60|watcher60@gmail.com|1322253925|watcher60|xx|0|90.202.97.251|Thanks - that did fix the issue.<br /><br />I still have the issue passing the arguments to the subroutine/object. (i.e the $args). I have managed to pass the entire question using the array rather than a string - i.e @args. &nbsp;with join. I'll posy back here the code when/if I figure it out!<br /><br />Thanks again for taking the time to help||||
