A small Python script for checking if a word is part of CFG (Context-free Grammar) or not. This script is implementing CYK (Cocke–Younger–Kasami) algorithm.
At the time, I couldn't find any simple/understandable implementation of CYK algorithm that I liked. If you have any questions feel free to create an issue.
Note
Your language must be in Chomsky form.
It's really straight forward. Change productions
and start_symbol
variables to your specific case. Then, just run it. Enter any word and see if it is part of the grammer.
- Include grammer from seperate JSON file in runtime
- Convert any CFG to Chomsky form
- Add some checks
Found a bug or better solution? Please report to the issue section.