This application allows you to create a grammar that it's in CNF (Chomsky Normal Form) and from it check if a given string input it's generated from it using CYK algorithm.
-
Clone this repository into your eclipse work-space.
-
Import this repository into your eclipse IDE.
-
Run program from main
-
Once it is open, the GUI will be shown with the following elements:
On screen you can see different tabs. The "Grammar" tab presents an interactive form where it is listed all necessary fields to create the grammar and add its production rules. The "CYK resume" tab presents the result of applying the CYK algorithm with an input string and the grammar it was created previously on the "Grammar" tab.
When you decide it is time to close the application you must click the "door out" icon.
-
Let's start by entering the main information for the grammar:
In the first section, you must need to enter the following:
The input string (a non empty string to be checked from the grammar and that it's required for the CYK algorithm) If you want to check the lambda symbol you must type "lambda".
The initial symbol (this specifies which is the first symbol that starts the production rules for the grammar. It's usually "S")
The set of terminals (this specifies which elements made up part of the terminals set for the grammar, separate each terminal by "," the program will do the rest. Remember "lambda" can be a terminal).
The set of symbols (this specified which elements made up part of the symbols set for the grammar, separate each symbol by "," the program will do the rest) Remember 'S' is also part of the symbols set.
If everything is right you can click on the button "add" to start adding the production rules. Once added you cannot overwrite the information you entered, be careful!
-
To add production rules:
In the second section, you must need to enter the head of the particular production you're adding, then in the body section you need to specify each body of the different productions rules (remember "lambda" can be a part of a body production). Look at the example above. You can add as much productions rules as the grammar contains,Once you have entered all your production rules you can now run the CYK algorithm.
-
To start the CYK algorithm:
To run the CYK algorithm, you just need to press the button "Start CYK decision algorithm" once done, on the CYK resume tab you will see the results of the execution.
-
To start with a new Grammar:
Once you have created your grammar and added its production rules, you can choose if you want to add a new grammar, once you have run the algorithm over the data you entered the form is restablished again, so you can enter new information.