1 Introduction
An impressive number of problems in the areas of natural language processing and document analysis and transformation can be viewed as text rewriting tasks (Roche and Schabes Reference Roche, Schabes, Roche and Schabes1997): using a collection of background rules and resources, a given input text has to be rewritten to another form. Examples include phonetic conversion (Laporte Reference Laporte, Roche and Schabes1997), stemming and lemmatization (Porter 1980; Krovetz Reference Krovetz1993; Maier 1995) and related forms of text normalization, tagging (Brill Reference Brill1992; Kupiec 92), shallow parsing and information extraction (Appelt et al. Reference Appelt, Hobbs, Bear, Israel and Tyson1993; Abney Reference Abney1997), semantic annotation and automated hyperlinking (Carr et al. Reference Carr, Hall, Bechhofer and Goble2001), automated text correction (Kukich Reference Kukich1992), translation (Brown Reference Brown2000) and others.
A simple, yet very useful variant of text rewriting is based on rewriting dictionaries that list strings that have to be replaced (“originals”) plus their substitutes. Rewriting dictionaries in this sense do not specify additional contextual conditions. Dictionary-based text rewriting simply means to replace occurrences of originals in an input text by their corresponding substitutes. Rewriting dictionaries in memory-based translation list words, phrases and sentences of a source language together with translations into a target language. In automated hyperlinking, rewriting dictionaries translate natural language expressions into ontological concepts, links and pointers. For shallow parsing and information extraction, rewriting dictionaries may be used that attach syntactic categories and semantic labels to words and phrases. Other rewriting dictionaries may help to substitute correct words for erroneous variants, or to replace synonyms by canonical forms. In cascaded approaches to natural language processing (Abney Reference Abney1997; Vogel Ney 2000), rewriting dictionaries may be used for transduction tasks that arise on one level.
From an algorithmic point of view, dictionary based text rewriting is complicated by the fact that occurrences of originals in a text may overlap. A strategy has to be given for resolving this kind of conflicts. Most actual text rewriting systems use the so-called “leftmost-longest match” replacement strategy with skips. Basically this means that there is a preference for replacing originals that start first in the natural (left-to-right) reading order. Among distinct originals with the same starting point, the longest one is replaced.Footnote 1 No overlap between replaced parts is possible.
It is straightforward to describe a naïve algorithm for text rewriting with a given rewriting dictionary D under the leftmost-longest strategy with skips: for each possible offset position k in the text t, we read the suffix s of t that starts at position k. As soon as we find a prefix p of s that does not represent a prefix of any original in D, or if we reach the end of t, we stop. If at this point we have already found an occurrence of an original string starting at position k, then we replace the longest of these originals by its substitute, using D. We then go back to the position immediately after the occurrence, k', and continue the search from k'. In the other case, if no occurrence starting at k has been observed, the first letter of s is passed to the output and we continue the search at position k' = k+1 of t.
Due to steps where we return to an earlier text position k', the worst-case time complexity of the naïve algorithm is O(m. |t|+|t'|), where m is the maximal length of an original string in the rewriting dictionary, |t| is the length of the text t and t' denotes the resulting output text. When using the naïve algorithm, such backward steps cannot be avoided. As a simple example, assume that the dictionary contains the pairs
When reading the text “a finite state transition diagram . . .” the algorithm will be forced to return to an earlier offset point when it finds that “ finite state t. . .” cannot be extended to “ finite state automaton”. Furthermore, the naïve algorithm needs some kind of special memory device that keeps track of the longest original string starting at offset position k found so far. This is due to the effect that originals of the rewriting dictionary may represent proper prefixes of other entries, as in the following example.

In this paper, we present an algorithm for dictionary-based rewriting that rewrites a given text t of length |t| in time O(|t|+|t'|), using the leftmost-longest match strategy with skips. The new algorithm does not use backward steps, and no memory device is needed: in our approach we compute, given the rewriting dictionary D, a subsequential finite state transducer
that always produces the desired transformation result in one deterministic run when applied to an input text t.Footnote 2
The construction of
represents a preprocessing step that is performed once. The number of states and transitions of
is linear in the size |D| of D. If implemented in a naïve way, output functions may have size cubic in |D|. Special string representation techniques help to reduce this to linear space without affecting the efficiency of the text rewriting. In this way, the time and space needed to compute
is linear in |D|. Our method for dictionary-based text rewriting can be described as a natural generalization of the well-known Aho-Corasick algorithm for multiple pattern search in texts (Aho and Corasick Reference Aho and Corasick1975)Footnote 3.
The advantage that is gained from the new method is twofold. Our algorithm for dictionary-based text rewriting is more efficient than the naïve algorithm. Furthermore, using standard tools, the above mentioned transducer
can be composed with other transducers, which helps to efficiently solve more complex text rewriting tasks in a single transduction step. In this way, a schematic translation of large vocabularies – which arises as a subtask in many of the above mentioned applications – can be naturally integrated into more ambitious text transformation systems. The method has been implemented and successfully tested with rewriting dictionaries with over 200,000 entries.
The paper is structured as follows. Section 2 provides some formal background. In Section 3 we illustrate the construction using a simple example. The algorithm for computing the subsequential transducer for text rewriting based on a given rewriting dictionary D is formally described in Section 4. In Section 5 we prove that the algorithm is correct. Section 6 presents a complexity analysis and implementation details. In Section 7 we evaluate the method. Section 8 comments on related work, focusing on finite state approaches. The Conclusion gives some ideas for further research.
2 Formal background
We assume that the reader is familiar with the basic notions of formal language theory as described, e.g., by Hopcroft, Motwani and Ullman (2000) or Kozen (Reference Kozen1997). More background on transducers and their use can be found in Roche and Schabes (Reference Roche, Schabes, Roche and Schabes1997). In the remainder of the paper, the symbols Σ and Δ always denote finite alphabets. As usual, Σ* (resp. Σ+) denotes the set of all (resp. all non-empty) strings over Σ, and similarly for Δ. The symbol ε denotes the empty word. If w is any string, then |w| denotes the length of w. The concatenation of the strings u and w is written u.w or uw. If f is any function, then Dom(f) denotes the domain of f.
2.1 Dictionary-based text rewriting with leftmost-longest-skip strategy
Definition 2.1 A rewriting dictionary is a partial function D :Σ+ → Σ* with finite domain. By an entry of D, we mean an element w of Dom(D). If w is an entry of D, the string D(w) is called the substitute for w. The set CoDom(D) := D(w) w ∈ Dom(D) is called the codomain of D.
In this paper, the terms “string” and “text” are used synonymously.
Definition 2.2
By an occurrence of a dictionary entry w in the t∈Σ*, we mean a triple 〈u,w,v〉ε(σ*)3 such that t=uwv. The strings u and v are respectively called the pre-text and the post-text of the occurrence.
Definition 2.3
The occurrence 〈u,w,v〉ε(Σ*)3 is called leftmost iff its pre-text is minimal with respect to all pre-texts of occurrences of dictionary entries in t. It is called leftmost-longest if it is leftmost and if w is of maximal length among all leftmost occurrences of dictionary entries in t. If there is any occurrence of a dictionary entry in t, then there exists a unique leftmost-longest occurrence, denoted lml D(t).
Example 2.4
Consider the rewriting dictionary D given by the mapping

and the text t=abcbbbabccb. Among nine distinct occurrences of dictionary entries in t, there are two occurrences of ab, which respectively have the form 〈ε, ab, cbbbabccb〉 and 〈abcbbb, ab, ccb〉. We have 〈ε, ab, cbbbabccb〉 = lml D(t).
Definition 2.5
The set of all leftmost-longest-skip occurrences of dictionary entries in t, denoted Lmls D(t) is recursively defined in the following way:
![\[
\Lmls_D(t) :=
\left\{\begin{array}{l}
\emptyset\quad\quad\mbox{iff there is no occurrence of an entry of} D \mbox{in} t;\\
\{\langle u,w,t'\rangle\}\ \cup\
\set{\tuple{uwu',w',v'}}{\tuple{u',w',v'}\in \Lmls_D(t')}\\
\quad\quad\mbox{iff} \lml_D(t) = \langle u,w,t'\rangle.
\end{array}\right.
\]](https://static.cambridge.org/binary/version/id/urn:cambridge.org:id:binary:20151127084828352-0455:S1351324905004092_eqnU4.gif?pub-status=live)
Remark 2.6
It is simple to see that two distinct occurrences 〈u, w, v〉, 〈u', w', v'〉 ∈ Lmls D(t) are always disjoint in the sense that either |u'|≥|uw| or |u|≥|u'w'|. Hence there exists a unique representation of t in the form t=u 1. w 1 . . . u k. w k. u k+1 where w i are entries of D (1≤ i≤ k) and u j ∈ Σ* (1≤ j≤ k+1) such that
Example 2.7
Let D denote the dictionary from Example 2.4, let t = abcbbbabccb. Then Lmls D(t) is the set with the following tuples:

Definition 2.8
The canonical lmls-extension of D is the function D lmls: Σ*→Σ* recursively defined in the following way:
Example 2.9
Let D denote the dictionary given in Example 2.4, let t= abcbbbabccb. Then D lmls (t) = ε · ε · bb · 4 ε · 5 b = 25bb45b.
The following corollaries follow immediately.
Corollary 2.10
Let 〈 u, w, v〉 ∈ Lmls D(t) where t= u. w. v. Then D lmls (t) = D lmls (u. w). D lmls (v).
Corollary 2.11
Let a 1 ∈ Σ. Assume that no prefix of t=a 1. t' is in the domain of D. Then D lmls (t) = a 1. D lmls (t').
2.2 Subsequential transducers
Definition 2.12
A subsequential transducer is a tuple
= 〈 Σ,Δ,Q, q 0, F, δ, λ, ε〉, where:
• Σ is a finite input alphabet;
• Δ is a finite output alphabet;
• Q is a finite set of states;
• q 0 ∈ Q is the start state;
• F Q is the set of final states;
• δ : Q × Σ → Q is a partial function called the transition function;
• λ : Q × Σ → Δ* is a partial function called the transition output function; we have Dom(λ) = Dom(δ);
• ε : F → Δ* is the state output function.
The extended transition function δ*: Q×Σ*→ Q is defined in the usual way:
Since δ is partial, the same holds for δ*, the definition is restricted to input strings that can be consumed by the transducer. Similarly we define the extended transition output function λ*: Q ×Σ*→ Δ* in the following way:
Also λ* is a partial function. The set L(
) = { t ∈ Σ* δ* (q 0, t)∈ F is called the input language of the transducer
. The subsequential transducer maps each word of the input language to an output word. The output function
of the transducer is defined as follows:
Denition 2.13
A subsequential transducer
is said to represent the function f: Σ* → Δ* iff
.
3 Informal description of the algorithm
Before we turn to the formal details of the algorithm, we use the dictionary

introduced in Example 2.4 to illustrate the main idea. The construction of the transducer for text-rewriting based on the dictionary D proceeds in two steps. The first step is straightforward.
First Step. We construct a tree-shaped transducer that represents (in the sense of Definition 2.13) the dictionary. To this end, we compute the trie for the domain Dom(D) of D. The output of each transition is set to the empty word. If w is an entry of D, then the final state corresponding to w emits the output D(w). Figure 1 shows the subsequential transducer trie
D for the rewriting dictionary D introduced in Example 2.4.
Subsequential transducer trie for the rewriting dictionary D introduced in Example 2.4.
Obviously the number of states in the resulting transducer
D does not exceed the total number of symbols in the list of all dictionary entries. In what follows, if q is any state of
D, then αq denotes the sequence of input transition labels of
D for the unique path leading from the start state q 0 to q.
Second Step. Given
D we construct a transducer
that represents (in the sense of Definition 2.13) the canonical lmls-extension D lmls of D. The set of states of
D is not modified. Similarly the output of the final states of
D is not changed. Furthermore, each transition of
D remains a transition of
. Hence,
D is only extended. Since
must accept any text, we must be able to depart from any state with any symbol of the input alphabet. This means that suitable failure transitionsFootnote 4. have to be added. Furthermore, each state has to be treated as a final state. The main difficulty is the definition of the output of failure transitions and final states. The reader should keep in mind that the output of a final state q is only emitted if we reach q at the end of the input string.
To introduce missing transitions and to define suitable outputs, we visit all states q of
D. For any state p, let d(q 0, p) denote the number of transitions in
D that are needed to reach p, starting from q 0. When we visit a state p we always assume that all states p' such that d(q 0, p') < d(q 0, p) have been visited before. We assume that a list (p 1, p 2., p h) is given that describes one possible visiting order for the states of Q D that respects this constraint. Note that q 0=p 1.
We begin with q 0. When reading a text t, we want to be in state q 0 at text position k only if k corresponds to an offset point where the naïve algorithm starts a new subscan. This means that position k is not inside a relevant left-most occurrence of an entry of D. Furthermore, the output for the prefix of the text ending at k is completed. State q 0 is declared to be final and the output is the empty string. For all letters σ where we do not have a transition from q 0 in
D, we add a transition σ with output σ to the transducer. Recall that the naïve algorithm outputs σ and immediately starts a new scan from position k+1. In our example, we have to add a transition for input letter d.
Definition of state outputs
The state output for a state q ≠ q 0, reached with the non-empty string αq, encodes the translation result D lmls(αq). A compositional description of D lmls(αq) can be obtained, analyzing how the naïve algorithm processes the string αq). Since αq represents a prefix of an entry of D, the algorithm proceeds in single forward move until the end of the string is found. At this point, a suitable output v is produced and the algorithm continues from a new offset point l > 0. The offset point l defines a partitioning of αq = u 1u 2 into substrings u 1, u 2 in the obvious way, cf. Figure 2.
Scanning a string αq representing a prefix of an entry of D.

Both v and l depend on the form of αq. If some prefix of αq represents an entry of D, and if u l is the maximal prefix of this form, then v = D(u l) and l marks the end of u l (for u 1 = αq, position l marks the end of the text.) Otherwise, if no prefix of αq is an entry of D, then v is the first letter of αq and l=k+1. Note that in both cases we have v= D lmls (u 1).
The output v represents a first component of the state output D lmls(αq) for q. The second component of D lmls(αq) corresponds to D lmls(u 2), the output of the naïve algorithm when processing u 2. The important point to note is that u 2 is shorter than αq. This guarantees that starting from q 0, all transitions for input u 2 are defined, and also the state output for the final state p' that is reached is already encoded in the present transducer. This leads to the following compositional description of the state output for q:

Using the partially defined transducer, all components are already available.
As an example, consider the situation in Figure 3, where states q 0 = p 1,. . . p 6 have been visited. For q=p 7 we have αq = abc, u 1=ab, u 2 = c. The state p' reached with u 2 = c is p' = p 4. Following the above equations, the state output for p 7 is D(ab).ε. 5=25. For q=p 8 we have αq = bab, u 1=b, u 2=ab, p'=p 5. Hence the output of p 8 is b. ε 2=b2.
Construction of the subsequential transducer for the canonical lmls extension of the dictionary given in Example 2.4. Situation after states q 0 = p 1,. . . p 6 have been visited.
Definition of target states and outputs for failure transitions. Consider a state q and a symbol Σ where we do not have a transition from q with Σ in
D. We first explain how to define the target state of the transition. When scanning α = qσ, the naïve algorithm proceeds in a forward move until it finds the letter Σ. Since by assumption α = qσ is not a prefix of an entry of D, the algorithm produces some output v and continues from a new offset point l>0. The offset point l defines a partition of αq =u 1u 2 in the obvious way. The situation is depicted in Figure 5. As above we have v = D lmls (u 1). Now assume that we process input u 2 (resp. u 2σ) with the transducer defined so far. Since u 2 is shorter than αq all needed transitions are already defined. We arrive at state p' (resp. q'). In this situation, q' represents the target state for the failure transition from q with Σ. Note that in general the path from q 0 to p' and q' may contain several failure transitions.
It may be shown that the string αq' represents a suffix of αqσ = w.αq' (cf. Part 1 of Lemma 5.2 below). The translation resultw of the corresponding prefix w, D lmls(w), represents the output of the failure transition. As above, for the algorithm we need a compositional description of D lmls(w).
Clearly, u l is a prefix of w=u 1. w 2. The choice of l as a backtracking point guarantees that D lmls(w)= D lmls (u 1). D lmlsw 2). We shall see in Lemma 5.2. Part 2, that D lmls(w 2) is the transition output of the transducer for input w 2.αq' = u 2.σ. Hence we obtain the following description of the output for the transition with letter σ from state q:
As above, using the partially defined transducer, all components are already available.
Again consider the situation in Figure 3, where states q 0=p 1. . ., p 6 have been visited. For q=p 7 and σ =d we have αq = abc, u 1=ab, u 2=c. The state p' reached with u 2=c (resp. u 2σ) is p 4 (resp. q 0). Hence the failure transition for q, d leads to q 0. Following the above equations, the transition output for the transition is 2. ε· 5d=25d. For q=p 8 and σ = d we have αq = bab, u 1=b, u 2=ab. The state p' reached with u 2 (resp. u 2σ) is p'=p 5 (resp. q 0). Hence the failure transition for q, d again leads to q 0. The transition output is b. ε. 2d=b2d.
The transducer
that is obtained after visiting all states of
D is shown in Figure 4.
The subsequential transducer for the canonical lmls extension of the dictionary given in Example 2.4.
Scanning substring αq·σ.
4 The algorithm
We now formally describe the construction of the subsequential transducer for text rewriting based on a dictionary D. As we made clear in the previous section, the constructions proceeds in two steps.
4.1 Construction of the subsequential transducer trie for the dictionary
The following construction of the subsequential transducer trie for a given rewriting dictionary D is well-known and only described for convenience and to fix notation. We assume that D is represented as a finite list of pairs of words of the form
Here αi ε Σ+, βiε Δ* and αi not = αj for 1 ≤ i, j ≤ n, i≠ j. We start with the empty transducer
0, which is defined as the tuple
Each of the following steps adds a new word pair to the subsequential transducer. Let us assume that we have constructed the subsequential transducer
representing the dictionary D k-1 = {〈αi, βi〉 ∈ D | i ∈ 1, 2,. . ., k−1}} for some k, 1 ≤ k ≤ n. We next have to add the pair 〈αk, βk to the transducer. Let αk = a 1 . . . a m and let a 1. . . a l denote the maximal prefix of αk such that δk-1*(a 1. . . a l) is defined. Here l≤ m. We introduce a set q' with m−l new states q l+1, q l+2, . . ., q m and define
where
and
Obviously,
k represents the dictionary D k = {〈αi, βi〉 ∈ D | 1 ≤ i ≤ k}. Hence, after n steps we obtain the transducer
which represents D.
D is tree-shaped, output is only produced when reaching a final state after completely consuming the input. Furthermore, each state q∈ Q D can be reached with exactly one word. As before, by αq we denote the unique string in Σ* such that δ*D(q 0, αq) = q and d(q 0,q)= | αq | denotes the number of transitions in
D that are needed to reach q, starting from q 0 (q∈ Q D).
4.2 Canonical lmls-extension of
D
To define the transducer
for text rewriting based on the given dictionary D we visit all states of
D. When visiting a state q, we declare q to be final, define the state output and add missing transitions such that for each σ∈ Σ we have exactly one transition departing from q with input letter σ. As described above, when visiting q we always assume that all states q' such that d (q 0, q') < d (q 0, q) have been visited before. We assume that a list (p 1, p 2, . . ., p h) is given that describes a possible visiting order for the states of Q D that respects this constraint. Note that q 0=p 1.
The transducer that results from our visit at q 0 is
where
Let us assume that after visiting p i (where 1 ≤ i < h) we have constructed the transducer
Let q=p i+1 denote the next state on our list of states to be visited. Let αq = a 1. . . a r. For 1 ≤ j ≤ r, let q j := δD*(q 0, a 1. . . a j). Hence q 0,. . ., q r denotes the sequence of states on the path of
D leading from q 0 to q. We distinguish two cases:
Case 1: Path q 0, q 1,. . ., q r does not contain a final state of
D. In this case, p′ := δi′*(q 0, a 2a 3 . . . a r) is defined, by choice of the visiting order. Let p′ := δ′i*(q 0, a 2a 3 . . . a r) and γ := a 1 . . . λ′i*(q 0, a 2a 3 . . . a r). We define
where
Case 2: Path q 0, q 1,. . ., q rcontains a final state of
D. Let q f denote the last final state of
D on this path.Footnote 5 This means that δD*(q 0, a 1a 2 . . . a f) = q f ∈ FD and q f+1, q f+2,. . ., q r cap F D = ∅. Let p′ := δ′i*(q 0, a f+1a f+2 . . . a r) and γ' := εD(q f) . . . λ'i* (q 0, a f+1a f+2. . . s a r). We define
where
The transducer
obtained after the final step h represents the output of our algorithm.
5 Correctness of the algorithm
We now show that the above algorithm is correct.
theorem 5.1
Let D be a rewriting dictionary. Then the transducer
computed by the above algorithm represents the canonical lmls-extension D lmls of D, in the sense of Definition 2.13.
The theorem follows immediately from Part 5 of the following Lemma.
Lemma 5.2
Let t = σ1. . . σn ∈ Σ*. Let q := δ*(q 0, t). Let α= αq denote the unique word such that δD* (q 0, α) = q. Then
1. α is a suffix of t.
Furthermore, if t = t0 · α, then
proof
We first remark that Property 5 is a consequence of the given partitioning of t and Properties 2-4. In fact, with α0 := α we obtain
To verify Properties 1-4 we use induction on the length n of the text t. If n=0, then t=t 0=α is the empty string and all claims are trivial. Assume that the claims are correct for n.
Let t' :=σ1. . .σnσn+1 and q' := δ*(q 0, t'). Let t=σ1. . .σn, q, t 0 and α as in the lemma.
Case 1. δD (q, σn+1) is defined. Then q' = δD (q, σn+1) and δD(q 0,α. . . σn+1) = q'. Obviously α = α σn+1 is a suffix of t' = t 0 . . . α', hence Claim 1 is satisfied. In what follows we consider the partitioning t' = t 0 α' of t'. We have λ (q,σn+1) = ε. Induction hypothesis 2 for t yields
which shows that Claim 2 is satisfied. Claim 3 is trivial. We prove Claim 4. Let α' have the form a 1a r. This means that a 1,. . ., a r is the sequence of input transition labels on the path of
D from q 0 to q'.
Subcase 1.1. First assume that there is no final state of
D on the path from q 0 to q′. In this case our construction implies that
Furthermore, no prefix of a 1 . . . a r belongs to the domain of D. Hence Corollary 2.11 yields D lmls(α) = D lmls (a 1. . . a r) = a 1D lmls (a 2. . . a r). Applying the induction hypothesis to the text a 2. . . a r we get (cf. Claim 5)
Hence D lmls(α')= ε(q'), which shows that Claim 4 is satisfied.
Subcase 1.2. There exists a final state of
D on the path from q 0 to q'. Let q f denote the last state on the given path that is final. Let a 1. . . a f denote the sequence of input transition labels from q 0 to q f. In this case our construction implies that
Furthermore, since a 1. . . a f is a leftmost-longest occurrence within α' = a 1. . . a r it follows from Corollary 2.10 (or from the recursive Definition 2.8) that D lmls(α′) = D lmls (a 1. . . a r)= D(a 1. . .a f). . .D lmls (a f+1. . . a r). Since the output of the final states of
D is not changed in
we have D(a 1. . . a f)= ε(q f). Since q 0≠ q f, the induction hypothesis (Claim 5) applied to a f+1. . . a r yields
Hence D lmls(α′) = Ψ(q′), which shows that Claim 4 is satisfied.
Case 2.1. δD(q,σn+1) is not defined and there is no final state of
Don the path from q 0 to q. Let a 1. . .a r denote the sequence of labels on the path from q 0 to q. In this case our construction yields q′ = δ(q,σn+1) = δ*(q 0,a 2. . .a rσn+1) and λ(q,σn+1)= a 1· λ*(q 0,a 2. . .a rσn+1). Let α′ denote the unique word such that δD(q 0,α′) = q′. The induction hypothesis applied to a 2. . .a rσn+1 shows that α′ is a suffix of a 2. . .a rσn+1 = α″·α′, hence α′ is a suffix of t′ = t 0 · a 1 · α″ · α′, which shows that Claim 1 holds. Let t 0′ := t 0 · a 1 · α″. Applying the induction hypothesis (Claim 3, α0 := a 1·α″) we get D lmls(t 0′) = D lmls(t 0) · D lmls(a 1 · α″). Our assumption implies that no prefix of a 1 · α″ is in the domain of D. Corollary 2.11 shows that D lmls(a 1 · α″) = a 1 · D lmls(α″), hence D lmls(t 0′) = D lmls(t 0) · a 1 · D lmls(α″). The induction hypothesis (Claim 2) for t yields D lmls(t 0) = λ*(q 0,t). The induction hypothesis (Claim 2) for a 2. . .a rσn+1 yields D lmls(α″) = λ*(q 0,a 2. . .a rσn+1). From the definition of the λi′-functions we get a 1 · λ*(q 0,a 2. . .a rσn+1)=λ(q,σn+1), hence we obtain
![\begin{equation}
D^{lmls}(t_0') &=& \lambda^\ast(q_0,t)\cdot a_1\cdot \lambda^\ast(q_0,a_2\ldots a_r \sigma_{n+1})\\[-2pt]
&=&\lambda^\ast(q_0,t)\cdot \lambda(q,\sigma_{n+1})\\[-2pt]
&=& \lambda^\ast(q_0,t').
\end{equation}](https://static.cambridge.org/binary/version/id/urn:cambridge.org:id:binary:20151127084828352-0455:S1351324905004092_eqnU36.gif?pub-status=live)
which proves Claim 2.
We prove Claim 3. Let γ ∈ σ*, let α0 be any prefix of α′·γ. By induction hypothesis (3) for t we have D lmls(t 0′·α0) = D lmls(t 0 · a 1 · α″·α0) = D lmls(t 0) · D lmls(a 1 · α″·α0). Our assumption implies that no prefix of a 1 · α″·α0 is in the domain of D. Corollary 2.11 shows that D lmls(a 1 · α″·α0)= a 1 · D lmls(α″·α0). Induction hypothesis (3) for a 2. . .a rσn+1 implies that D lmls(α″·α0) = D lmls(α″) · D lmls(α0). Hence we have D lmls(t 0′·α0) = D lmls(t 0) · a 1 · D lmls(α″) · D lmls(α0). As above it follows that D lmls(t 0) · a 1 · D lmls(α″)= D lmls(t 0′), which proves Claim 3.
Since q′ = δ*(q 0,a 2. . .a rσn+1) the induction hypothesis for a 2. . .a rσn+1 yields D lmls(α′) = Ψ(q′), which shows that Claim 4 is satisfied.
Case 2.2. δD(q,σn+1) is not defined and there is a final state of
D on the path from q 0to q. Let a 1. . .a r denote the sequence of labels of the path from q 0 to q, let q f denote the last final state on the path and let a 1. . .a f denote the sequence of labels of the path from q 0 to q f.
In this case we have q′ = δ(q,σn+1) = δ*(q 0,a f+1. . .a rσn+1) and λ(q,σn+1)= ΨD(q f) · λ*(q 0,a f+1. . . a rσn+1). Let α′ denote the unique word such that δD(q 0,α′) = q′. The induction hypothesis applied to a f+1. . .a rσn+1 shows that α′ is a suffix of a f+1. . .a rσn+1=α″·α′, hence α′ is a suffix of t′ = t 0 · a 1 . . . a f · α″ · α′, which shows that Claim 1 holds. Let t 0′ := t 0 · a 1 . . . a f · α″. Applying the induction hypothesis (Claim 3, α0 := a 1 . . . a f · α″) we get D lmls(t 0′) = D lmls(t 0) · D lmls(a 1 . . . a f · α″). Our assumption implies that a 1 . . . a f represents a longest leftmost occurrence within a 1 . . . a f · α″. Corollary 2.10 shows that D lmls(a 1 . . . a f · α″) = D lmls(a 1 . . . a f) · D lmls(α″)=ΨD(q f) · D lmls(α″), hence D lmls(t 0′) = D lmls(t 0) · ΨD(q f) · D lmls(α″). The induction hypothesis (Claim 2) for t yields D lmls(t 0) = λ*(q 0,t). The induction hypothesis (Claim 2) for a f+1. . .a rσn+1 yields D lmls(α″) = λ*(q 0,a f+1. . .a rσn+1). We obtain
![\begin{equation}
D^{lmls}(t_0') &=& \lambda^\ast(q_0,t)\cdot \Psi_D(q_f)\cdot \lambda^\ast(q_0,a_{f+1}\ldots a_r \sigma_{n+1})\\[-2pt]
&=&\lambda^\ast(q_0,t)\cdot \lambda(q,\sigma_{n+1})\\[-2pt]
&=& \lambda^\ast(q_0,t'),
\end{equation}](https://static.cambridge.org/binary/version/id/urn:cambridge.org:id:binary:20151127084828352-0455:S1351324905004092_eqnU37.gif?pub-status=live)
which proves Claim 2.
We prove Claim 3. Let γ ∈ Σ*, let α0 be any prefix of α′·γ. By induction hypothesis (3) for t we have D lmls(t 0′·α0) = D lmls(t 0 · a 1. . . a f · α″·α0) = D lmls(t 0) · D lmls(a 1. . . a f · α″·α0). Our assumption and Corollary 2.11 show that D lmls(a 1. . . a f · α″·α0)= ΨD(q f) · D lmls(α″·α0). Induction hypothesis (3) for a f+1. . . a rσn+1 implies that D lmls(α″·α0) = D lmls(α″) · D lmls(α0). Hence we have D lmls(t 0′·α0) = D lmls(t 0) · ΨD(q f) · D lmls(α″) · D lmls(α0). As above it follows that D lmls(t 0) · ΨD(q f) · D lmls(α″) = D lmls(t 0′), which proves Claim 3.
Since q′ = δ*(q 0,a f+1. . .a rσn+1) the induction hypothesis for a f+1. . .a rσn+1 yields D lmls(α′) = Ψ(q′), which shows that Claim 4 is satisfied.
6 Complexity analysis and implementation details
In this section we show that a naïve representation of the transducer output function needs cubic space. We then introduce a pointer-based representation with linear space requirement. Even with this step, a straightforward implementation would lead to quadratic running time. In the last subsection we present a queue-based iterative transducer construction which computes the intended rewriting transducer in linear time and space.
6.1 Cubic space complexity of transducer output function
It is simple to see that the number of states of the resulting transducer
for an input dictionary D is bounded by the size (number of symbols) of the domain of D. In fact, states of
represent states of the transducer trie, which correspond to prefixes of entries of D. Since the alphabet is fixed, the number of transitions of
is linear in the size of Dom(D). The following example shows that the size of the output functions can become cubic in the size (number of symbols) of D when using the standard representation for output strings.
Example 6.1
Let n ≥ 1. Consider the rewriting dictionary D of the form
where 1n (a n) denotes a sequence of n symbols 1 (a). Then the size of a single transition/state output is quadratic, which means that the size of the transition/state output function is cubic. The corresponding transducer for n=4, which illustrates this phenomenon, is shown in Figure 6.
The subsequential transducer for the canonical lmls-extension of the dictionary given in Example 6.1.
The following proposition shows that the size of the output functions is at most cubic in the size of D. As before, for any state q, by αq we denote the unique word in Σ* such that δD*(q 0,αq)=q.
Proposition 6.2
Let λ and Ψ respectively denote the transition and state output function of
, let q∈ Q, σ∈ σ. Let i=| αq |. Then
1. Ψ(q) can be represented as a concatenation of ≤ i strings representing either elements of CoDom(D) or symbols from Σ, and
2. λ(q,σ) can be represented as a concatenation of ≤ i+1 strings representing either elements of CoDom(D) or symbols from Σ.
Proof
Part 1 directly follows from Part 4 of Lemma 5.2. Here α represents the input of length i leading from q 0 to q. Clearly D lmls(α) can be represented in the described form.
Part 2: It is simple to see that λ*(q 0,αq)=ε since the relevant transitions are already present in the transducer trie for D,
D. Hence we have λ*(q 0,αqσ)=λ(q,σ). We consider the text t= αqσ. Let q′ = δ*(q 0,t). By Part 1 of Lemma 5.2, αq' is a suffix of t. The corresponding prefix w of t= w · αq′ has length ≤ i+1. Part 2 of Lemma 5.2 now yields λ(q,σ) = λ*(q 0,t)=D lmls(w). Clearly D lmls(w) can be represented in the described form.
6.2 Linear representation of the output function
A closer inspection of the recursive definition of the output functions given in Section 4.2 shows that a linear representation of the output function is possible. The key idea is to use pointers to represent the strings γ′ defined in Cases 1 and 2 of the construction of
i+1′ (here and in what follows we use the notation introduced in Section 4.2). We write γq′ for γ′ in order to make the correspondence to q (the state for which γ′ is defined) more obvious.
In the algorithm, “old” outputs of the final states of the transducer trie and the empty transition outputs already defined in the trie are not modified. In Case 1 of the transducer construction (cf. Section 4.2), “new” state and transition outputs for q are respectively defined as
In Case 2, new state and transition outputs for q are respectively defined as
Recall that the states p′ and q r−1 are closer to the start state than q. From these equations we see that the following representation is possible. We will construct the output string using a record, which contains either a conventional string, a symbol from Σ, or two pointers to other records. Let π1 and π2 be pointers. Assume that π1 points to the location of π2. By redirecting π1 we mean the process where we let π1 point to the same address as π2.
• “Old” outputs of the final states of the transducer trie and the empty transition outputs already defined in the transducer trie are represented as pointers to records containing conventional strings.
• To represent a new state output Ψ(q) we use a pointer to a new record with two pointers. The first (second) pointer points to a record representing γ′q (resp. Ψ(p′)). If γ′q or Ψ(p′) is empty, the corresponding pointer is suppressed and Ψ(q) is redirected to the record pointed by the other pointer. If both γ′q and Ψ(p′) are empty, Ψ(q) is redirected to point to the empty word record.
• To represent the output of a new transition, λ(q,σ), we use a pointer to a new record with two pointers. The first (second) pointer points to a record representing γ′q (resp. λ(p′,σ)). If γ′q or λ(p′,σ) is empty, the corresponding pointer is suppressed and λ(q,σ) is redirected to the record pointed by the other pointer. If both γ′q and λ(p′,σ) are empty, λ(q,σ) is redirected to point to the empty word record.
• In the case where r=1 (Case 1) or r=f (Case 2) γ′q is represented by a pointer to a new record containing the letter a 1 (Case 1) or a pointer to the record pointed by Ψ(q f) (Case 2). For r > 1 (Case 1) or r > f (Case 2) γ′q is represented by a pointer to a new record which contains two pointers. The first one points to the record pointed by γq r−1′ (Cases 1,2). The second pointer points to the record pointed by λ(δ*(q 0,a x. . .,a r−1),a r) where x=2 in Case 1 and x=f+1 in Case 2. If γq r−1′ or λ(δ*(q 0,a x. . .,a r−1),a r) is empty, the corresponding pointer is suppressed and γ′q is redirected to the record pointed by the other pointer. If both γq r−1′ and λ(δ*(q 0,a x. . .,a r−1),a r) are empty, then γ′q is redirected to point to the empty word record.
Example 6.3
In Figure 7 we see the subsequential transducer for the local extension of the dictionary given in Example 6.1 with the pointer-based representation of output functions. The string γ′q for each state q is written below q. Small numbers in bold face denote pointers. Pointer addresses/values are written in brackets. For example, the state reached from the initial state with input a has state output 1111. Pointer 3 points to 1111. The state output of the state q reached with input aa, which is written 3.3 in the pointer-based representation, thus has the form 1111 · 1111. The output of the transition from q with input letter b is written 3.4. Decoding pointers we obtain 3.4 = 3.3.2 = 1111 · 1111 · b.
The subsequential transducer for the canonical lmls-extension of the dictionary given in Example 6.1 with the pointer-based representation of output functions.
In fact, concatenating the strings that are found when following the pointers in the obvious order yields the correct output strings. As to the representation size, the important point to note is that we need a constant number of pointers per state q. Besides the pointers, each output of the trie transducer (i.e., each element of the codomain of D) and each letter of the alphabet needs to be represented once. It follows that the representation size of the transducer is linear in the size of D.
Since each member of a pair of pointers always points to a non-empty string, and since there are no chains of single pointers, when applying the transducer to a text t the number of pointers that have to be processed to produce a partial output string β is bounded by the length of β plus 1 (1 for empty output). Hence the complexity of text rewriting O(|t|+|t′|) is not affected by this special technique for representing outputs.
6.3 Linear computation of the rewriting transducer
It is not completely obvious how to modify the algorithm described in Section 4 in order to obtain the correct pointer representation for the outputs. Furthermore, a naïve implementation of the algorithm leads to a time complexity which is quadratic in the worst case. The problem is that the calculation of p' and γ′ (cf. Cases 1 and 2) requires a traversal of the transducer with a suffix a 2. . . a r (Case 1) or a f+1. . . a r (Case 2) of the word αq. The length of αq, as the length of the suffix, may be linear in the input, and it seems necessary to do the traversal for each state.
To overcome these problems, during the breadth-first traversal of the trie we maintain a queue. The queue contains triples with the following entries:
1. the state to be processed – q,
2. the state p' which is reached by traversing the transducer with the string obtained by removing the first symbol, or the string on the path from the last final state, depending on the case, and
3. a pointer to the representation of γq′.
In the algorithm, triples are calculated in constant time from predecessor triples, using the equations given in the previous subsection.
Consider the situation presented in Figure 8. The triple 〈q old, p old′, γold′ has been calculated. Reaching state q new with letter a r in the trie, we want to define the new triple. We distinguish two cases.
Calculation of a triple from the predecessor triple.

Situation I: If q new is not a final state of
D (situation depicted in Figure 8), then p new′=δ(p′old,a r) and γ′new = γ′old · λ(p′old,a r). The equation for γ′new follows directly from the above equivalences (cases r > 1, r > f). The equation for p′new directly follows from the definition of the state p' in Section 4.2. It is important to note that the transition from p′old to p′new may be a failure transition.
Situation II: If q new is a final state in the trie, then we define p′new=q 0 and γ′new=Ψ(q new). Both equations follow directly from the second case distinguished in Section 4.2 where f=r.
We give the pseudo-code of the algorithm in a Pascal-like language (like the language used in (Aho et al. 1983)). We assume that an implementation for the Abstract Data Type (ADT) “Transducer State” is given. Later we presume that NULL is the null constant for an arbitrary abstract data type.
On Transducer State we will need the following types and operations:
1. FIRST_CHAR, LAST_CHAR – these are the first and the last character in the input alphabet;
2. STATE – a pointer to a structure representing a transducer state;
3. function NEW_STATE : STATE; – function returning a new state;
4. function FINAL(STATE) : boolean; – returns true if the state is final and false otherwise;
5. procedure SET_FINAL(STATE, boolean); – defines the finality of the state in accordance with the boolean parameter;
6. function TRANSITION(STATE, char) : STATE; – returns the state to which the transducer transits from the parameter state with the parameter char;
7. procedure SET_TRANSITION(STATE, char, STATE); – the procedure defines the transition from the first state by the char to the second state;
8. function STATE_OUTPUT(STATE) : POutString; – returns the output string of a final state;
9. procedure SET_STATE_OUTPUT(STATE, POutString); – defines the output string of a final state;
10. function OUTPUT(STATE, char) : POutString; – returns the output string for the transition given by the state and the char;
11. procedure SET_OUTPUT(STATE, char, POutString); – defines the output string for the transition given by the state and the char;
12. procedure SAVE_TRANSDUCER(file, STATE); – saves the transducer to the file, starting from the initial state.
Now we are ready to present the pseudo-code of our algorithm.
Below the special representation of the output strings is given. An output string is either a character, or a substitute for a dictionary entry, or a concatenation of two already defined strings represented by pointers. In line 11 we define the type for the queue records as triples containing two states and one pointer to OutString.
Here we define the global variables used in the algorithm.
The next three functions below are used to efficiently concatenate two OutStrings, save an ordinary string in an OutString, and to represent a character as an OutString. The first of the three functions – ConcatOutStrings – checks the two parameters. If both of them point to the empty string, then the empty string is returned. If one of the parameters points to the empty string, then a pointer to the other one is returned. In the remaining case, the function returns a pointer to a new structure with exactly two pointers pointing to the two input parameters respectively. The second function – StringToOutString – returns a pointer to a structure containing a given input string. The last of the three functions – CharToOutString returns a pointer to a structure containing a given input character.
The following procedure describes the treatment of one triple from the queue. Processing a triple means to declare q to be final, to add state output of q, failure transitions for state q and to maintain the queue by adding triples for the trie successor states. For the definition of state outputs and failure transitions see Section 4.2 and the above equations. In lines 46–56, for each letter c an appropriate action is taken: either a failure transition is added or a new triple is calculated and added to the queue.
The main program has three parts.
First (lines 58–79), the transducer trie is computed by reading the input dictionary line by line.
Second (lines 80–95), the initial state q 0 is treated. We set its output to the empty string and add loops for all symbols σ of the alphabet for which there are no outgoing transitions from the starting state. The transition outputs are identical to the corresponding input symbol σ (line 87). If there is already an outgoing transition with the given symbol σ in the trie, then we put the following triple in the queue: the state q reached from q 0 with σ, the starting state (here playing the role of p'), and the representation for γ′, which here is either σ (line 92) or the output of q if this state represents a final state of the trie (line 90), depending on the situation.
Third (lines 96–99), the triples in the queue are processed. As seen above the procedure Process_State adds new triples to the queue. The queue is used in order to process the states in ascending distance from the starting state.
Clearly the above algorithm implements the method described in the previous sections. Reading the input dictionary takes time proportional to the size of the dictionary. The procedure for building the trie has time complexity proportional to the number of trie states. The number of steps required for processing a single state in the Complement_State procedure is proportional to the alphabet size. The space requirements for a state are proportional to the alphabet size as well. Thus the space and time complexity of the given algorithm is O(|D|+m+|Σ| · m), where m is the number of states in the trie transducer. Obviously m < Σ〈αi,βi〉∈ D|αi| thus the time complexity of the algorithm is proportional to the size of the dictionary for a fixed alphabet.
7 Empirical results
We implemented both the algorithm described in Section 4 and the naïve algorithm described in the introduction. For the latter implementation, a trie is used to encode the dictionary. In this way we may efficiently check if a string is a prefix of a dictionary word. When the naïve algorithm is applied to a text, any new input symbol gives rise to a single transition step in the trie. We obtain an efficient realization since we have to go back only in the cases where we went too far in the trie.
To compare both methods, we made a series of experiments, varying the size of the input alphabet, the number of dictionary entries, and the average length of dictionary entries. All dictionary words were randomly generated, varying both the length and the form using a regular distribution. We then measured the time for rewriting a randomly generated text. Table 1 presents the speed-up factor (ratio of times) of our method compared to the naïve algorithm. For three of the entries the rewriting transducer was too large to be hold in the operating memory.
Results for text rewriting using random rewriting dictionaries, speed-up factors (ratio of times) w.r.t. naïve algorithm
The algorithm is currently applied in the context of OCR-correction (Strohmaier et al., Reference Strohmaier, Ringlstetter, Schulz and Mihov2003a; Strohmaier et al., Reference Strohmaier, Ringlstetter, Schulz and Mihov2003b), using rewriting dictionaries that rewrite erroneous words into correction suggestions. We successfully compiled transducers for a variety of rewriting dictionaries. For the experiments we used a conventional PC (Intel(R), Pentium IV, CPU 3.2 GHz with 1 GB RAM main memory running Linux). The largest dictionary had 221,681 entries. The number of states of the transducer was 737,792. The number of transitions was 737,792× 42 (alphabet size 42). The construction time for the transducer was 33.60 seconds. Using the constructed transducer, 134 MB of text (18,470,101 tokens) were rewritten in 7.71 seconds. For the sake of comparison, the same text was rewritten with the naïve algorithm, which took 12.79 seconds (speed-up factor 1.66x). The size of the rewriting subsequential transducer is 278 MB. The size of the minimal subsequential transducer representing the dictionary without rewriting (constructed using the method presented in Mihov and Maurel (Reference Mihov and Maurel2001)) is 4.3 MB.
8 Related work
Applications of finite state transducers for different problems of natural language processing are described, e.g., in Kaplan and Kay (Reference Kaplan and Kay1994), Mohri (Reference Mohri1996, Reference Mohri1997) and Roche and Schabes (Reference Roche, Schabes, Roche and Schabes1997). Rewriting dictionaries as discussed in this paper can be considered as a special form of rewriting rules in the sense of Kaplan and Kay (Reference Kaplan and Kay1994). Ignoring weighted versions (Mohri Reference Mohri, Junqua and Noord2001), such a rewriting rule has the form α↦ β /λ_ρ. The rule expresses that occurrences of α that are immediately preceded by an occurrence of λ (left context) and directly followed by an occurrence of ρ (right context) are replaced by β. Here α, β, λ and ρ are regular expressions, which implies that in general we have a proper rewriting relation (as opposed to a rewriting function). In order to formally define the rewriting relation, distinct modes of applying the rule must be distinguished: left-to-right versus right-to-left application, optional versus obligatory application. Kaplan and Kay (Reference Kaplan and Kay1994) proved that all these rewriting relations are rational, i.e., they can be encoded by a finite state transducer. Kartunnen (1997) describes a similar approach. In Karttunen (Reference Karttunen1996), also the difference between longest match versus shortest match strategies is considered. For the leftmost-longest match strategy, the construction described in Kaplan and Kay (Reference Kaplan and Kay1994) has been improved by Gerdemann and van Noord (Reference Gerdemann and van Noord1999). Another improvement of Kaplan and Kay (Reference Kaplan and Kay1994), applicable also for weighted rewrite rules, is presented by Mohri and Sproat (Reference Mohri and Sproat1996) and Mohri et al. (1996). It should be noted that the above approaches lead to non-deterministic transducers.
Theoretically the above techniques can be applied for the construction of a subsequential transducer that represents D lmls. To this end, a determinization procedure (Roche and Schabes 1995) must be used. This would lead, however, to a much more indirect and complex construction, which in practice could be applied only for very small dictionaries.
Roche and Schabes (1995) show how the contextual rewrite rules used in Brill's tagger (Brill Reference Brill1992) can be compiled into subsequential finite state transducers. The rules have the form w↦ v /λ_ρ where w,v are tags and the context conditions λ and ρ restrict the previous and next tags. Hence the rules represent a special form of the above rewrite rules. Roche and Schabes show that any rewriting relation represented as a finite state transducer
1 can be transformed into a transducer
2 that represents the “local extension” of
1: If
1 produces output w for input v, and if u and x are any strings where
1 does not apply, then
2 rewrites uvx into uwx. Hence,
2 is used to perform all possible
1-replacements inside a given text. Recall that our transducer uses the more restricted leftmost-longest replacement strategy with skips. From the theoretical results proved at the end of Roche and Schabes (1995) it follows that the lmls-extension D lmls of a finite rewriting dictionary D can be represented as a subsequential transducer. But at this point no explicit construction is given.
The problem considered in the present paper is more restricted in the sense that our rewrite rules ignore contextual conditions. Furthermore, we only consider one fixed application mode (obligatory leftmost-longest replacement strategy with skips). For this specific problem, a simple and efficient solution directly leading to a deterministic transducer is given.
The problem of how to represent a given rewriting dictionary D (as opposed to the canonical lmls-extension D lmls) as a minimal subsequential transducer is discussed in Mohri (Reference Mohri1996). This construction provides a very fast dictionary lookup as well as compact storage. An on-line algorithm for constructing the minimal subsequential transducer for a given dictionary is presented in Mihov and Maurel (Reference Mihov and Maurel2001), building up on ideas from Mihov (Reference Mihov1998) and Daciuk et al. (2000).
The wide variety of text rewriting applications mentioned in the introduction, which could be extended by further examples from compiler construction, computer virus/worm detection, and network traffic intrusion detection, explains that many techniques have been established for solving algorithmic tasks similar to the one studied above. An exhaustive comparison is outside the scope of the paper. Yet, subtle differences have to be taken into account that explain why methods from one domain cannot be naively transferred to the present task. For example, text rewriting in translation and compiler construction is based on tokenized text, hence problems with overlapping originals do not occur.
9 Conclusion
In this paper we have shown how to compute for a given rewriting dictionary, D, a subsequential finite state transducer
that represents the canonical lmls-extension D lmls of D and thus can be used for text-rewriting based on D using the leftmost-longest replacement strategy with skips. The resulting speed of the text-rewriting procedure can hardly be improved since the text is deterministically rewritten in one linear scan of the input. Theoretically, the size of the output functions of
can become cubic in the size of the input dictionary D when using a standard implementation. In practice, however, the size of the output functions is typically small and the real limitations are caused by the number of transducer states and transitions (which is linear in the size of D for fixed alphabet size). We also showed how special encoding techniques for output strings help to compute
in time and space linear in the size of D.
The entries of our rewriting dictionaries represent non-contextual rewrite rules. Naively, a contextual rule of the form v↦ w / l_r (where v,w,l,r are strings) can be written as a non-contextual rule lvr↦ lwr. However, this changes the semantics of the contextual rule because in the new version the right context r can no longer serve as left context to the next rule application. As an example, consider the two contextual rules a↦ 1 / bb_ab and aa↦ 22 / b_b, which are respectively translated into bbaab↦ bb1ab and baab↦ b22b. Using the contextual version of the rules, the text bbaab is translated into bb 22b under the leftmost-longest strategy. In contrast, using the translated version we obtain bb 1ab.
In future work we intend to investigate how other replacement strategies can be realized with modified transducer constructions.
Acknowledgments
The authors thank the referees of the Journal of Natural Language Engineering. Their comments helped to improve the presentation.
that accepts any text t as input and outputs the intended rewriting result under the so-called “leftmost-longest match” replacement with skips, t'. The time needed to compute the transducer is linear in the size of the input dictionary. Given the transducer, any text t of length |t| is rewritten in a deterministic manner in time O(|t|+|t'|), where t' denotes the resulting output text. Hence the resulting rewriting mechanism is very efficient. As a second advantage, using standard tools, the transducer can be directly composed with other transducers to efficiently solve more complex rewriting tasks in a single processing step.
