Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with some tags #1

Open
dreamingechoes opened this issue Feb 13, 2014 · 9 comments
Open

Problem with some tags #1

dreamingechoes opened this issue Feb 13, 2014 · 9 comments

Comments

@dreamingechoes
Copy link

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?

@robertjwhitney
Copy link
Owner

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!

@dreamingechoes
Copy link
Author

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):

srai

@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
}

end srai

I hope you find it helpful.

Greetings!

@robertjwhitney
Copy link
Owner

@dreamingechoes great. I didn't really write the library just ported it over to a gem.

@robertjwhitney
Copy link
Owner

hey @dreamingechoes I will accept a pull-request if you think you have a fix.

@drusepth
Copy link
Contributor

drusepth commented Jan 9, 2016

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).

@boykoc
Copy link
Contributor

boykoc commented Jan 18, 2017

Both of these issues are addressed in the following PRs: #7 #5. See these for updated code.

@decampj4
Copy link

@robertjwhitney - when you get a chance, could you publish a release with these patches please?

@robertjwhitney
Copy link
Owner

@decampj4 no problem, published it just now

@decampj4
Copy link

@robertjwhitney thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants