Open dreamingechoes opened 10 years ago
Hi,
I also discovered some tags were presenting problems during my tests. For instance, I had to create a subset of the ALICE AML ( located here: https://github.com/robertjwhitney/alice-programr ).
I didn't end up with enough time to patch it, but I'm happy to assist if you track it down or accept a patch if you want to submit a pull request.
Thanks!
Hello,
I have been analyzing the source code of the gem, and I think I know what happens (at least with Srai tag). In the "AIML Parser", in the three blocks concerning the tag, the first initialize an object (currentSrai = Srai.new), and add to "openLabels" that object. But in the second block, create a new one, and the text is added to the new object, which is not the one in "openLabels" so that reference is lost. I just commented the line of code where you create a new object Srai, and has worked for me. I dont know if this happens with more tags, as I focused on the tag Srai.
Piece of code (lib/programr/aiml_parser.rb, lines 185 et seq):
@parser.listen(%w{ srai }){|uri,localname,qname,attributes|
currentSrai = Srai.new
openLabels[-1].add(currentSrai)
openLabels.push(currentSrai)
}
@parser.listen(:characters, %w{ srai }){|text|
# currentSrai = Srai.new <========= ¡¡¡¡ Problem here !!!!
currentSrai.add(text)
}
@parser.listen(:end_element, %w{ srai }){
currentSrai = nil
openLabels.pop
}
I hope you find it helpful.
Greetings!
@dreamingechoes great. I didn't really write the library just ported it over to a gem.
hey @dreamingechoes I will accept a pull-request if you think you have a fix.
I submitted a PR for srai
.
Looks like there's still an off-by-one error in random
to hunt down (AFAICT it never selects the last li
).
Both of these issues are addressed in the following PRs: #7 #5. See these for updated code.
@robertjwhitney - when you get a chance, could you publish a release with these patches please?
@decampj4 no problem, published it just now
@robertjwhitney thank you very much!
Hello,
I discovered this gem a few days ago, and I use it for a project but I'm having trouble because some tags (like "srai" and "sr") do not work properly, simply do not return any response. Am I the only one with this error?