3 ms·
It's true that most natural languages cannot be parsed with a CFG, but he gives the wrong example. In fact, the language of the grammar that he describes can pe
by danieldk 15y ago
It's true that most natural languages cannot be parsed with a CFG, but he gives the wrong example. In fact, the language of the grammar that he describes can perfectly be generated by a CFG. E.g. for a rule such as:
sentence --> noun_phrase(Num), verb_phrase(Num).
You could create the CFG equivalent:
sentence --> noun_phrase_sg, verb_phrase_sg.
sentence --> noun_phrase_pl, verb_phrase_pl.
It sure is a drag, but this is how many CFG grammars/parsers work. Of course, it's generally agreed upon that DCGs generalize better even when used with grammars that can be described with a CFG.
Most natural languages are not context-free, but he gives the wrong example. To provide a more convincing example - in Dutch you can construct phrases like:
dat ik Marie Jan de dozen zie helpen inpakken (lit: that I Marie Jan the boxes see helping packing)
The NPs and the verbs correspond in the following manner: ik - zie, Marie - helpen, Jan - Inpakken. Or, more formally, the structure is: np_a np_b np_c np_x v_a v_b v_c. Of course, this highly resembles a COPY language, which cannot be expressed using a CFG, but (obviously!) can be expressed using a DCG:
s(L) --> w(L), w(L)
w([a|Rst]) --> [a], w(Rst).
w([b|Rst]) --> [b], w(Rst).
w([]) --> []
(This grammar parses/generates a string of zero or more a's and b's, followed by exactly the same string.)