learn and forget capabilities|yvesago|agostini@univ-metz.fr|1212476034|yvesago|xx|0|193.50.117.72|a simple way to add learn and forget capabilities on one keyword<br /><br />[code]+ &#123;weight=10000&#125;learn * *<br />- learning &lt;star1&gt;. &lt;call&gt;learn &lt;star1&gt; &lt;star2&gt;&lt;/call&gt;<br /><br />&gt; object learn perl<br /> &nbsp;my ($rs,$args,@args2) = @_;<br /><br /> &nbsp;return if ( length $args &lt;= 2) ;<br /><br /> &nbsp;my $msg = join(&quot; &quot;,@args2);<br /> &nbsp;my $cmd = &quot;<br />+ [\*] $args [\*]<br />- $msg<br />&quot;;<br /><br /> &nbsp;$rs-&gt;stream ($cmd);<br /> &nbsp;$rs-&gt;sortReplies();<br /><br /> &nbsp;return &quot;success! $args learned.&quot;;<br />&lt; object<br /><br />+ &#123;weight=10000&#125;forget *<br />- &lt;call&gt;forget &lt;star&gt;&lt;/call&gt;<br /><br />&gt; object forget perl<br /> &nbsp;my ($rs,$args) = @_;<br /><br /> &nbsp;return if ( length $args &lt;= 2) ;<br /><br /> &nbsp;my $cmd = &quot;<br />+ [\*] $args [\*]<br />&quot;;<br /><br /> &nbsp;$rs-&gt;stream ($cmd);<br /><br /> &nbsp;$rs-&gt;sortReplies();<br /><br /> &nbsp;return &quot;success! $args forgeted.&quot;;<br /><br />&lt; object<br />[/code]||||
Re: learn and forget capabilities|Casey|casey@cuvou.net|1213924615|Kirsle|xx|0|72.37.252.50|Cool idea, but your learning pattern is ambiguous:<br /><br />[code]+ learn * *[/code]<br /><br />What does each * match? if you say &quot;learn hello bot hello human&quot;, &lt;star1&gt; could be &quot;hello&quot; and &lt;star2&gt; &quot;bot hello human&quot;, or &lt;star1&gt; could be &quot;hello bot hello&quot; and &lt;star2&gt; be &quot;human&quot;, or any other combination.<br /><br />Here's a better way of doing it, and getting it to save the file for later on so when the bot's reloaded it'll remember it still.<br /><br />[code]+ &#123;weight=100&#125;learn *<br />- &lt;set learning=&lt;star&gt;&gt;I will learn a response to &quot;&lt;star&gt;&quot;. Type the response now.&#123;topic=learning&#125;<br /><br />&gt; topic learning<br />   + *<br />   - Learning reply... &lt;call&gt;learn &lt;id&gt;::&lt;get learning&gt;::&lt;sentence&gt;&lt;/call&gt;&#123;topic=random&#125;<br />&lt; topic<br /><br />&gt; object learn perl<br />   my ($rs,@args) = @_;<br />   my $in = join(&quot; &quot;,@args);<br />   my ($id,$pattern,$reply) = split(/::/, $in, 3);<br /><br />   my $code = &quot;// Taught by: $id\n&quot;<br />      . &quot;+ $pattern\n&quot;<br />      . &quot;- $reply\n\n&quot;;<br /><br />   # Append it to contrib.rs so it'll be reloaded later on.<br />   open (APPEND, &quot;&gt;&gt;./rscripteg/contrib.rs&quot;);<br />   print APPEND $code;<br />   close (APPEND);<br /><br />   # Stream it in.<br />   $rs-&gt;stream ($code);<br />   $rs-&gt;sortReplies();<br /><br />   return &quot;Success!&quot;;<br />&lt; object[/code]<br /><br />Having it forget a reply is a bit tricky though. Just having a +trigger with no -response isn't that great (you'll end up with &quot;ERR: No Reply Found&quot;, because it found a match to the trigger but no associated reply. You'd have to get into the module's internals to really delete a trigger...<br /><br />[code]+ &#123;weight=100&#125;forget *<br />- Forgetting that trigger... &lt;call&gt;forget &lt;get topic&gt; &lt;star&gt;&lt;/call&gt;<br /><br />&gt; object forget perl<br />   my ($rs,$topic,@args) = @_;<br />   my $trig = join(&quot; &quot;,@args);<br /><br />   if (exists $rs-&gt;&#123;topics&#125;-&gt;&#123;$topic&#125;-&gt;&#123;$trig&#125;) &#123;<br />      delete $rs-&gt;&#123;topics&#125;-&gt;&#123;$topic&#125;-&gt;&#123;$trig&#125;;<br />      $rs-&gt;sortReplies();<br />      return &quot;forgotten!&quot;;<br />   &#125;<br />   else &#123;<br />      return &quot;I never knew that trigger...&quot;;<br />   &#125;<br />&lt; [/code]<br /><br />That would only delete it from memory but not erase it from contrib.rs, but if ya really wanted to you could have it read the file, delete those lines, and save it again. :)<br /><br />Anyway, here's my example in action:<br /><br />[code][kirsle@fonality RiveScript-1.15]$ ./rsdemo <br />Welcome to the Perl RiveScript Interpreter. This script is a demonstration<br />of RiveScript. The bot's replies are taken from the files in the<br />'rscripteg' directory, which by default are based on some of Eliza's<br />triggers and responses.<br /><br />You're now chatting with the RiveScript bot. Why not say hello? When<br />you get tired of this, type &quot;quit&quot; to exit this demonstration.<br /><br />You&gt; learn all your base are belong to us<br />Bot&gt; I will learn a response to &quot;all your base are belong to us&quot;. Type the response now.<br />You&gt; we get signal<br />Bot&gt; Learning reply... Success!<br />You&gt; k <br />Bot&gt; Does talking about this bother you?<br />You&gt; all your base are belong to us<br />Bot&gt; We get signal<br />You&gt; ^C<br /><br />[kirsle@fonality RiveScript-1.15]$ ./rsdemo <br />Welcome to the Perl RiveScript Interpreter. This script is a demonstration<br />of RiveScript. The bot's replies are taken from the files in the<br />'rscripteg' directory, which by default are based on some of Eliza's<br />triggers and responses.<br /><br />You're now chatting with the RiveScript bot. Why not say hello? When<br />you get tired of this, type &quot;quit&quot; to exit this demonstration.<br /><br />You&gt; all your base are belong to us<br />Bot&gt; We get signal<br />You&gt; forget all your base are belong to us<br />Bot&gt; Forgetting that trigger... forgotten!<br />You&gt; all your base are belong to us<br />Bot&gt; Did you think they might not be belong to us?<br />You&gt; [/code]||||
Re: learn and forget capabilities|echoline|echoline@gmail.com|1264040123|echoline|xx|0|71.117.203.164|i ported badanswer.aiml to rs. &nbsp;it seems to be working ok.||||badanswer.rs
Test, just a test|XRumerTest|yourmail@gmail.com|1305965826|XRumerTest|xx|0|60.29.249.85|Hello. And Bye.||||
Test, just a test|XRumerTest|yourmail@gmail.com|1305965923|XRumerTest|xx|0|60.29.249.85|Hello. And Bye.||||
