next up previous
Next: Longest Match Capturing Up: The Algorithm Previous: Preliminary Considerations


A rule of the form $x \rightarrow T(x)/\lambda\mbox{\_\_}\rho$will be written as replace(T,Lambda,Rho). Rules of the more general form $x_1 \ldots x_n \Rightarrow T_1(x_1) \ldots
T_n(x_n)/\lambda\mbox{\_\_}\rho$ will be discussed in §3. The algorithm consists of nine steps composed as in figure 1.

Figure 1: Definition of replace operator.
... remove the auxiliary 0's.\end{verbatim}\end{tex2html_preform}\par

The names of these steps are mostly derived from [7] and [12] even though the transductions involved are not exactly the same. In particular, the steps derived from Mohri & Sproat (r, f, l1 and l2) will all be defined in terms of the finite state calculus as opposed to Mohri & Sproat's approach of using low-level manipulation of states and transitions.3

The first step, non_markers, was already defined above. For the second step, we first consider a simple special case. If the empty string is in the language described by Right, then r(Right) should insert an rb2 in every string position. The definition of r(Right) is both simpler and more efficient if this is treated as a special case. To insert a bracket in every possible string position, we use:

[[[] x rb2,sig]*,[] x rb2]

If the empty string is not in Right, then we must use intro(rb2) to introduce the marker rb2, followed by l_iff_r to ensure that such markers are immediately followed by a string in Right, or more precisely a string in Right where additional instances of rb2 are freely inserted in any position other than the beginning. This expression is written as:


Putting these two pieces together with the conditional yields:

  if([] & R,       % If: [] is in R:
     [[[] x rb2,sig]*,[] x rb2], 
      intro(rb2)   % Else:

The third step, f(domain(T)) is implemented as:

macro(f(Phi), intro(lb2)

The lb2 is first introduced and then, using l_iff_r, it is constrained to occur immediately before every instance of (ignoring complexities) Phi followed by an rb2. Phi needs to be marked as normal text using non_markers and then xign_x is used to allow freely inserted lb2 and rb2 anywhere except at the beginning and end. The following lb2^ allows an optional lb2, which occurs when the empty string is in Phi.

The fourth step is a guessing component which (ignoring complexities) looks for sequences of the form lb2 Phi rb2 and converts some of these into lb1 Phi rb1, where the b1 marking indicates that the sequence is a candidate for replacement. The complication is that Phi, as always, must be converted to non_markers(Phi) and instances of b2 need to be ignored. Furthermore, between pairs of lb1 and rb1, instances of lb2 are deleted. These lb2 markers have done their job and are no longer needed. Putting this all together, the definition is:

    [lb2 x lb1,
     rb2 x rb1]
   ]*, xsig*]).

The fifth step filters out non-longest matches produced in the previous step. For example (and simplifying a bit), if Phi is ab*, then a string of the form ... rb1 a b lb1 b ... should be ruled out since there is an instance of Phi (ignoring brackets except at the end) where there is an internal lb1. This is implemented as:4

          ),     % longer match must be
          rb     % followed by an rb 
         ]))     % so context is ok
% done with rb2, throw away:

The sixth step performs the transduction described by T. This step is straightforwardly implemented, where the main difficulty is getting T to apply to our specially marked string:

         o T o 
    rb1 x []

The seventh step ensures that lb1 is preceded by a string in Left:


The eighth step ensures that lb2 is not preceded by a string in Left. This is implemented similarly to the previous step:


Finally the ninth step, inverse(non_markers), removes the 0's so that the final result in not marked up in any special way.

next up previous
Next: Longest Match Capturing Up: The Algorithm Previous: Preliminary Considerations
Noord G.J.M. van