<< Prev | - Up - |
The implemented syntax rules.
Luckily, there's a simple trick that will make a limited form of coordination available to us. We'll add an auxiliary set of categories named np2
, np1
, v2
, v1
, etc. These auxiliary categories allow us to specify left-recursive rules to a certain depth of recursion. For example, the rules which have something to say about NPs will be replaced by the following:
A DCG allowing only limited recursion.
np2--> np1.
np2--> np1, coord, np1.
np1--> det, noun2.
np1--> pn.
Similarly, the rules controlling nouns will become:
noun2--> noun1.
noun2--> noun1, coord, noun1.
noun1--> noun.
noun1--> noun, pp.
noun1--> noun, rc.
While this is a rather blunt way of dealing with the problem of left recursion in a grammar, it enables us to parse the examples we want without having to implement a more sophisticated parser.
Another shortcoming of these rules should be mentioned. As you might have noticed by now, we've imposed limits on inflectional morphology---all our examples are relentlessly third-person present-tense. This is a shame, since tense and its interaction with temporal reference is a particularly rich source of semantic examples. Nonetheless, we shall not be short of interesting things to do.
englishGrammar.pl
: View Download
But for all its shortcomings, this small set of rules (to be found in englishGrammar.pl
) assigns tree structures to an interesting range of English sentences:
``Mary loves every owner of a siamese cat.''
``John or Mary smokes.''
``Every man that loves a woman visits a therapist.''
``John does not love a therapist or woman that smokes.''
``If a therapist talks then a man works.''
If you want to test the grammar, you will have to do this within a semantic framework, e.g. -calculus:
lambda([mary,knows,every,owner,of,a,siamese,cat],Sem).
<< Prev | - Up - |