% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % File: err_trap.dtr % % Purpose: illustrate error trapping for ill-formed queries % % Author: Gerald Gazdar, 6th October 1995 % % Email: geraldg@cogs.sussex.ac.uk % % Address: COGS, Sussex University, Brighton BN1 9QH, UK % % Version: 1.10 % % % % Copyright (c) University of Sussex 1995. All rights reserved. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Left to its own devices, the DATR default mechanism will often provide an % answer to queries that are ill-formed in the context of the assumptions % made by the designer of the fragment. This matters little if one can be % confident that all the queries actually made will be well-formed. But % if this is not a plausible assumption to make then such spurious answers % may be the source of hard-to-locate bugs in the NLP system in which the % DATR lexicon is embedded. In such circumstances, it may make sense to % include error trapping in the fragment itself. This file illustrates % one technique that may be used to that end. The node CheckPath is just % a finite state recognizer for well-formed queries. All queries (except % those beginning with '-') are submitted to it for checking before they % are returned (now with a '-' prefix) to the original node for an answer. % Clearly, in this illustration, some external mechanism is required to % ensure that no queries beginning with '-' are submitted. The example % below can also easily be reworked so that queries are required to begin % with '-' whilst the verb fragment itself is free of that prefix. % % Although a finite state syntax for well-formed queries has been assumed % for simplicity in the present example, there is nothing to prevent one % writing versions of CheckPath for more sophisticated notions of well- % formedness (e.g., by using a DATR-encoded RTN). Bad_Path: % The user needs to comment out one of the two equations: == true % == false <> == <> % If is true, an error message is returned: == 'Error: ill-formed query path' % If is false, then the ill-formed path ends up undefined: == UNDEFINED. GoodPath: <> == "<->". # vars $tempor: past pres. # vars $number: sing plur. # vars $person: one two three. CheckPath: <> == Bad_Path == GoodPath == Bad_Path == GoodPath == Bad_Path == GoodPath == Bad_Path. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % A very simple example theory augmented with error trapping VERB: <> == CheckPath <- mor passive> == "<- mor past>" <- mor past> == "<- mor root>" ed <- mor pres> == "<- mor root>" <- mor pres participle> == "<- mor root>" ing <- mor pres tense sing three> == "<- mor root>" s. Love: <> == VERB <- mor root> == love. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Some example theorems: % % Love: % <> = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = love % = Error: ill-formed query path % = Error: ill-formed query path % = love % = love s % = Error: ill-formed query path % = love % = love % = love % = Error: ill-formed query path % = love ing % = Error: ill-formed query path % = Error: ill-formed query path % = Error: ill-formed query path % = love ed % = love ed % = love ed % = Error: ill-formed query path % = love ed % = love ed % = love ed % = love ed % = love ed. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % # hide CheckPath Bad_Path GoodPath VERB. # show <> . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % The next line is the Revision Control System Id: do not delete it. % $Id: archive.dtr,v 1.1 1997/04/09 20:40:33 root Exp $