It is straightforward to represent FSTNs in Prolog and to write programs to perform various operations with them. Our approach here will be to represent networks declaratively as data structures (facts in the Prolog database) that can be examined and manipulated. We will then write general purpose recognition and generation programs that will work on any network represented as a data structure in the approved way.
Before we start writing general network traversal programs, we need to consider how we are going to represent transition networks as Prolog data structures. We need to know the following about a network:
- what its initial nodes are - what its final nodes are - what its arcs are, where each arc is defined by: - the departure node - the destination node - the label on the arc
This can be represented most straightforwardly in Prolog by using simple predicates of the appropriate kind:
initial(Node). final(Node). arc(DEPARTURE_NODE,DESTINATION_NODE,LABEL).
Here are some example networks (the ENGLISH1 example appears in the appendix in the file "fstnarcs.pl"):
% Swahili-1 % initial(1). final(5). arc(1,2,subj). arc(2,3,tense). arc(3,4,obj). arc(4,5,stem).
Code:fstnarcs.pl % ENGLISH1 % initial(1). final(9). arc(1,3,np). arc(1,2,det). arc(2,3,n). arc(3,4,bv). arc(4,5,adv). arc(4,5,'#'). arc(5,6,det). arc(5,7,det). arc(5,8,'#'). arc(6,7,adj). arc(6,6,mod). arc(7,9,n). arc(8,9,adj). arc(8,8,mod). arc(9,4,cnj). arc(9,1,cnj).
Something is missing from these network definitions (at least, under their intended interpretations), namely a statement of what such symbols as 'subj' abbreviate. We could readily adopt the following style of declaring these abbreviations:
abbreviates(subj,[ni,u,a,tu,wa]).
But, for reasons of consistency with our treatment of the lexicon in subsequent example programs, we will adopt here a more verbose, but equivalent form of declaration:
word(CATEGORY,WORD).
Here the CATEGORY argument corresponds to the abbreviation symbol, and WORD corresponds to one of the items subsumed under this abbreviation. Under this scheme, here are the abbreviations for ENGLISH1:
word(np,kim). word(np,sandy). word(np,lee). word(det,a). word(det,the). word(det,her). word(n,consumer). word(n,man). word(n,woman). word(bv,is). word(bv,was). word(cnj,and). word(cnj,or). word(adj,happy). word(adj,stupid). word(mod,very). word(adv,often). word(adv,always). word(adv,sometimes).
Although this is verbose, it is not inefficient: it may involve a Prolog interpreter in just as much work to search down a list checking membership as it does to search through its data base looking for the appropriate 'word' entry.
Send us a comment.