From what I understand, in Prolog you capture features while parsing like so:
foo(feature(X)) --> [X], bar.
Is this common when designing DCGs ?
foo(featureA(X), featureB(Y)) --> [X], [Y], bar.
From what I understand, in Prolog you capture features while parsing like so:
foo(feature(X)) --> [X], bar.
Is this common when designing DCGs ?
foo(featureA(X), featureB(Y)) --> [X], [Y], bar.
DCGs describe relations between lists and the non-terminals' arguments. However, these arguments are just terms. They can be used to represent features but do not represent them directly. To see the difference, imagine you want to associate a feature numerus to each node. In DCGs you have now to decide, case by case, how to represent that feature. In one node it is feature(X, singular)
and in another node it might look different. Or you might decide to represent all features uniformly with a list, thus [nodename=idx,..., numerus=singular,...]
.
It's perfectly valid, and quite useful. As an example, consider this rule, taken from the classic (and now free!) book PNLA, which uses two arguments to capture the inflection and the "meaning" (the logical form, LF
) of a transitive verb tv
:
tv(nonfinite, LF) --> [TV], {tv(TV, _, _, _, _, LF)}.
tv(finite, LF) --> [TV], {tv(_, TV, _, _, _, LF)}.
tv(finite, LF) --> [TV], {tv(_, _, TV, _, _, LF)}.
tv(past_participle, LF) --> [TV], {tv(_, _, _, TV, _, LF)}.
tv(pres_participle, LF) --> [TV], {tv(_, _, _, _, TV, LF)}.
A verb can then be defined as
tv( write, writes, wrote, written, writing, X^Y^ `writes(X,Y) ).
tv/6
) are indexed by all the arguments. A faster lexicon representation would be tv(written, past_participle, X^Y^writes(X,Y))
. –
Hipbone © 2022 - 2024 — McMap. All rights reserved.