(Message 7) From: HELEN HPS (on ERCC DEC-10) Date: Wednesday, 16-Jan-85 14:07:26-GMT To: ecmi08@2972,Pain@EDXA Via: uk.ac.edinburgh.edxa ; (to uk.ac.edinburgh.emas) 16 Jan 85 14:14:30 gmt Msg ID: <132001-455-241@EDXA> -------- /* GENERAL-PURPOSE ACTIVE CHART PARSER */ /* Independent of grammatical formalism used, although the formalism */ /* will have to have some general resemblance to a phrase-structure */ /* grammar for a chart to work at all. The phrase-structure grammar */ /* terms "rule", "LHS", "RHS" have been used here for simplicity, */ /* but they should be interpreted fairly abstractly. */ /* All the external interfaces are in terms of 3 data-types: */ /* surface words */ /* syntactic categories */ /* edge-labels */ /* syntactic structures */ /* requirements (RHSs of rules) */ /* An edge-label is a functor with 3 components: */ /* */ /* label(, , ) */ /* */ /* The interface to the dictionary is via the procedure */ /* */ /* word_to_label(, ) */ /* */ /* which performs lexical look-up and formats the answer as a label */ /* The interface to the grammar is via the procedures: */ /* */ /* rules_with_this_LHS(, ) */ /* rules_with_this_RHS(, ) */ /* */ /* which find appropriate rules and format them into labels. */ /* The procedure "initial_category(X)" should return the */ /* top symbol of the grammar. */ /* The user should define a predicate "valid_parse" which the system */ /* will apply to all analyses which span the whole string at the end */ /* of the parsing process. Only those on which this predicate succeeds */ /* will be returned from the function "parse". If "valid_parse" is */ /* left undefined, all spanning parses will be returned. */ /* (This facility requires Prolog to be run in a way such that */ /* undefined procedures do not cause errors). */ /* The interface to the building of syntactic structures is via the */ /* procedures: */ /* is_empty_structure(). */ /* which tests for a structure being empty, */ /* and */ /* compute_requirements(, , */ /* ). */ /* which, from previous "requirements" of active edge, and "category" */ /* of the inactive edge, computes the "requirements" of the new edge. */ /* Also, */ /* combine_structures(, , ). */ /* builds syntactic results (roughly, attaches 2 to 1 as daughter). */ /* */ /* (Combining two edges (Fundamental Rule) needs these to be defined). */ /* The user may vary the strategies or edge-policies using: */ /* */ /* set_strategy(). */ /* set_policy(). */ /* The actual chart edges are held in the ordinary clause database */ /* for easy access. The functor is edge/3. */ /* The main external top-level interface is the routine "parse" which */ /* takes a list of surface words and returns a list of valid parses. */ /* No printing routines are provided - this is specific to the structures */ /* being built, which is another issue which depends on the formalism. */ parse(Wordlist, Listofparses):- /* Top-level routine - takes ordinary list of words and */ /* returns list of all valid parses. */ current_strategy(Strategy), /* Find out what current strategy */ current_policy(Policy), /* and policy are. */ initialise_chart(Wordlist, Policy,Agenda), /* Preliminary setting up */ /* Now invoke main recursive function, with a null "agenda" and */ /* a vertex-number of 1. Result returned is total vertex count */ parse_onwards(Policy, Strategy, Agenda, Wordlist, 1, Noofvertices), /* And read the valid parses off the chart. */ extract_parses(Noofvertices, Listofparses). initialise_chart(Wordlist, Policy, Agenda):- /* The chart is held in the ordinary clause database, as a */ /* set of assertions "edge(