Simple java program converting Context Free Grammar to Chomsky Normal Form
$10-30 USD
ปิดแล้ว
โพสต์ มากกว่า 9 ปีที่ผ่านมา
$10-30 USD
ชำระเงินเมื่อส่งงาน
Must be well documented so end users can make sense of the code
Write a Java program, using only the classes in the Java SE 7 , that:
1. Reads a proposed context-free grammar (CFG) from a text file (I tell you the format below). You must ask the user to select the text file with a JFileChooser. Your program must determine whether or not the text file contains a legal CFG. If not, report it and terminate. Otherwise, proceed to step 2.
2. Converts the grammar into Chomsky Normal Form. Suppose that the initial text file was abc.txt. Then your program should produce the following 4 text files, stored in the same directory as [login to view URL]:
a. File [login to view URL] contains the grammar with a new start variable
b. File [login to view URL] contains the grammar from [login to view URL] with all ε transitions removed
c. File [login to view URL] contains the grammar from [login to view URL] with all unit rules removed
d. File [login to view URL] contains the grammar in Chomsky Normal Form
Notes on the program specification:
1. The CFG in the input text file will have one production on each line, with single upper-case letters denoting variables and Σ = {0,1}. “e” denotes epsilon. The initial start variable will be “S”. Each production in the input file will be in the following format, where <U> denotes an upper case letter and <t> denotes a terminal (0, 1, or ε):
<U>:<some legal right-hand-side of a production>
2. When you create a new start variable, call it “T”.
3. All new variables you create should be single, upper-case letters.
4. The maximum number of productions in the original grammar may be limited to 10. No production will have more than 3 symbols on the right-hand side.
5. The maximum size of a string to test would be 6 characters.
Here are some examples of what the CFGs in the input text files may look like:
S:0S1
S:e
S:0A
S:1B
A:01
A:0A
B:10
B:1B
B:e
Hello friend,
I have 5 very intelligent developers who are proficient in solving string problems and 3 of them being best in java. I assure that we will work with single minded dedication to write quality code that satisfy your needs.
In hope to get an opportunity to write the code for you.
-Nikhil