2.3.6 Putting it in Prolog

Translate the transducer specifications into the Prolog format that we used in the last lecture.

If you want to implement the small morphological parser that we have seen in the previous section, all you really have to do is to translate the transducer specifications into the Prolog format that we used in the last lecture. Then, you can use last lecture's transducer program to let them run.

We won't show in detail what the transducers look like in Prolog, but we want to have a quick look at the e insertion transducer, because it has one interesting feature; namely, the other- transition. How can we represent this in Prolog?

Assuming the transducer is called c1, here are all transitions that go out of state 6 in Prolog notation, except for the other-transition.

trans(c1,6,2,z:z).
trans(c1,6,2,s:s).
trans(c1,6,2,x:x).
trans(c1,6,3,'^':'^').

Now, the other-transition should translate any symbol except for z, s, x, ^ to itself. In Prolog, we can express this using cuts and exploiting the fact that Prolog searches the database top down:

trans(c1,6,2,z:z) :- !.
trans(c1,6,2,s:s) :- !.
trans(c1,6,2,x:x) :- !.
trans(c1,6,3,'^':'^') :- !.
trans(c1,6,1,X:X) :- !.


Kristina Striegnitz, Patrick Blackburn, Katrin Erk, Stephan Walter, Aljoscha Burchardt and Dimitra Tsovaltzi
Version 1.2.5 (20030212)