next up previous contents
Next: Subsumption Checking (parsing only) Up: Running and Debugging ALE Previous: Executing Grammars: Generation   Contents


Mini-interpreter (parsing only)

[Code]
ALE contains a mini-interpreter that allows the user to traverse and edit an ALE parse tree. By default, the mini-interpreter is off when ALE is loaded. To turn the mini-interpreter on, simply type:
  | ?- interp.

  interpreter is active

  yes
  | ?-
To turn it off again, use nointerp. Any parse automatically stores the following information on the edges added to ALE's chart: The spanning nodes are the nodes in the chart that the edge spans. The substring spanned is the concatenation of lexical items between the spanning nodes. If an edge was formed by the application of an ALE grammatical rule, its creator is that rule, with the daughters being the daughters of the rule, i.e., the cat>, and cats> of the rule). If the rule was created by EFD closure, the mini-interpreter will treat it as the user's rule it was created from, displaying the empty categories that had matched its daughters during EFD closure in the same way as daughters matched at run-time. If an edge represents an empty category, its creator is normally empty; but empty categories created during EFD closure will show the rules that created them, along with their empty category daughters. If an edge represents a lexical item, its creator is lexicon. In the case of empty categories not created by EFD closure and all lexical items, there are no daughters.

The status of the mini-interpreter has no effect on compilation. The same code is used regardless of whether the mini-interpreter is active or inactive. The mini-interpreter only has an effect on the run-time commands rec/1,2,4,5 and drec/1.

When the mini-interpreter is active, rec/1 operates in one of two modes: query-mode or go-mode. When the mini-interpreter is active, rec/1 always begins in query-mode. In query-mode, the user is prompted just before any edge is added. Because ALE parses from right to left, the edges are encountered in that order. The prompt consists of a display of the feature structure for the edge, followed by the mini-interpreter information for that edge, followed by an action-line, which lists the options available to the user. For example (from the HPSG grammar included in the ALE distribution):

  | ?- rec([kim,sees,sandy]).

  STRING: 
  0 kim 1 sees 2 sandy 3

  word
  QRETR list_quant
  QSTORE e_set
  SYNSEM synsem
         LOC loc
             CAT cat
                 HEAD noun
                      CASE case
                      MOD none
                      PRD bool
                 MARKING unmarked
                 SUBCAT e_list
             CONT nom_obj
                  INDEX [0] ref
                        GEN gend
                        NUM sing
                        PER third
                  RESTR e_set

  Edge created for category above: 
        from: 2 to: 3
      string: sandy 
        rule:  lexicon
   # of dtrs: 0

  Action(add,noadd,go(-#),break,dtr-#,abort)? 
  |:
We see, in this example, the main action-line for rec. If the user selects add, the edge is added, and rec proceeds, in query-mode, as usual. If noadd is selected, the edge is not added, and rec proceeds in query-mode. In every ALE action-line, the first option is the one that ALE would have chosen if the mini-interpreter were disabled.

go puts the mini-interpreter into go-mode. In go-mode, rec proceeds as it would if the mini-interpreter were inactive, or to think of it another way, it functions as if the user always chose the first option on every action-line, but it does not stop to ask. As it adds the edges, it displays them, along with their mini-interpreter information. go suffixed with a number, e.g., go-1, puts the mini-interpreter into go-mode until it encounters an edge whose left node is that number, and then, beginning with that edge, automatically switches back into query-mode. With ALE's current parsing strategy, go- N will remain in go-mode until it encounters the first edge corresponding to the (N+1)st lexical item in the string being parsed.

break simply invokes the Prolog break commmand, placing the user into a Prolog interpreter with a new break-level. Edges that have been added so far can be examined and retracted at this time. When the user pops out of the break, the current prompt is redisplayed.

dtr-N displays the Nth daughter, its mini-interpreter information, and the action-line for dtr:

  Action(retract,dtr-#,parent,abort)?
  |:
retract removes the displayed edge (in this case, the daughter) from the chart. When the parse continues, ALE grammar rules will not be able to use that edge. The current edge (the parent of this daughter), however, can still be added. dtr-N has the same effect as in the rec action-line. parent returns to the current edge's parent and its action-line (either rec or dtr).

The mini-interpreter will not display any edge that has already been retracted. Note that if edges are retracted, there may be gaps in the sequence of chart-edge indices.

If abort is selected, the parse is aborted. All of the edges added so far remain in memory until the next rec statement. The edge that was displayed when abort was chosen is discarded.

Mini-interpreter information is also available through the run-time commands, edge/2 and edge/1, e.g.:

  | ?- edge(2,4).
  
  COMPLETED CATEGORIES SPANNING: every toy 
  
  cat
  QSTORE ne_list_quant
         HD every
            RESTR toy
                  ARG1 [0] individual
            SCOPE proposition
            VAR [0] 
         TL e_list
  SYNSEM basic
         SEM [0] 
         SYN np

  Edge created for category above: 
       index: 20
        from: 2 to: 4
      string: every toy
        rule:  np_det_nbar
   # of dtrs: 2
  Action(retract,dtr-#,continue,abort)? 
  |:
Every edge that is actually asserted into the chart is assigned a unique number, called an index, which edge/2 displays also. retract and dtr behave the same as in the dtr action-line. continue tells the mini-interpreter that the user is done traversing the parse tree rooted at the current edge, and to find more.

edge/1 works exactly as edge/2 does, except that its input is the unique index number that ALE stores with every edge.


next up previous contents
Next: Subsumption Checking (parsing only) Up: Running and Debugging ALE Previous: Executing Grammars: Generation   Contents
TRALE User's Manual