Skip to content

Commit 4357b2a

Browse files
committed
Update README.md
1 parent 9d928ea commit 4357b2a

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ S -> Starting Symbol
1515
a b -> Terminals
1616
S A B E C X Y Z -> Non-Terminals
1717
S YB XA * -> 4th and all following lines are production rules
18-
E YB XA -> You can add multiple to one terminal if you seperate them by a space
18+
E YB XA -> You can add multiple non-terminal -> (terminal|non-terminal) relations if you seperate them by a space
1919
A a YE XC -> This reads as A -> a | YE | XC
2020
B b XE YZ
2121
C AA
@@ -30,7 +30,7 @@ After you compiled the .java file you can simply run it via
3030
java CYK <GrammarFile> <Word>
3131
```
3232

33-
Sample output for the supplied grammar above:
33+
Sample output for the supplied grammar above using the word abbabaa:
3434

3535
```
3636
$ java CYK grammar.txt abbbabaa
@@ -72,3 +72,40 @@ Applying CYK-Algorithm:
7272
7373
The word abbbabaa is an element of the CFG G and can be derived from it.
7474
```
75+
## Grammars with token words
76+
77+
This application also supports token words, that means you define a terminal as a whole string. The token detection gets triggered automatically once you pass more than two arguments. Sample output below.
78+
79+
```
80+
$ java CYK test.txt test is a test
81+
Word: test is a test
82+
83+
G = ({this, is, a, test}, {S, A, B, E, C, X, Y, Z}, P, S)
84+
85+
With Productions P as:
86+
A -> this | YE | XC
87+
B -> is | XE | YZ
88+
C -> AA
89+
E -> YB | XA
90+
S -> YB | XA | *
91+
X -> a
92+
Y -> test
93+
Z -> BB
94+
95+
Applying CYK-Algorithm:
96+
97+
+--------+--------+--------+--------+
98+
| test | is | a | test |
99+
+--------+--------+--------+--------+
100+
| Y | B | X | Y |
101+
+--------+--------+--------+--------+
102+
| E,S | - | - |
103+
+--------+--------+--------+
104+
| - | - |
105+
+--------+--------+
106+
| - |
107+
+--------+
108+
109+
The word "test is a test" is not an element of the CFG G and can not be derived from it.
110+
```
111+

0 commit comments

Comments
 (0)