-
Notifications
You must be signed in to change notification settings - Fork 12
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
left-recursive grammar breaks the parser #12
Comments
Wow, good point. There is nothing wrong with the grammar, but in the way I represent the grammar to efficiently calculate probabilities. It's been a while, I hope I still understand it enough to investigate. |
I suspect it's just for the edge case of this minimal, almost trivial example. Investiginating now. |
Confirmed: happens for edge cases where p=1.0 and matrix is indeed singular. Shouldn't be hard to fix. |
@digitalheir Awesome! Thanks for mentioning what the problem was. I tried having a look at the code just out of curiosity, but since I familiar only with CYK and not Earley parser, I could not really understand what was happening except that there is a matrix somewhere which has a 0 determinant. |
I've been silly. Of course we get strange results if the program assigns P=1.0 to each rule by default. I had the idea to normalize the probabilities as above example yields P(A)=1+1=2, an illegal probability. So should normalize to [0.5, 0.5] so that P(A)=1.0. I never got around to implementing it and have acted as if it's no problem. Easier fix than I had thought! |
I tried the following grammar:
Reading it like this:
Results in:
Converting the grammar to right-recursive avoids this issue:
I am using the latest version in Maven:
0.9.12
Is there something I misunderstood about the behaviour of the grammar or is this bug?
The text was updated successfully, but these errors were encountered: