An orthography change is defined by the \ch field code followed by the actual orthography change.  Any number of orthography changes may be defined in the text output control file.  The output of each change serves as the input the following change.  That is, each change is applied as many times as necessary to an input word before the next change from the text output control file is applied.

Basic changes
-------------

To substitute one string of characters for another, these must be made known to the program in a change.  (The technical term for this sort of change is a production, but we will simply call them changes.)  In the simplest case, a change is given in three parts: (1) the field code \ch must be given at the extreme left margin to indicate that this line contains a change; (2) the match string is the string for which the program must search; and (3) the substitution string is the replacement for the match string, wherever it is found.

The beginning and end of the match and substitution strings must be marked.  The first printing character following \ch (with at least one space or tab between) is used as the delimiter for that line. The match string is taken as whatever lies between the first and second occurrences of the delimiter on the line and the substitution string is whatever lies between the third and fourth occurrences.  For example, the following lines indicate the change of hi to bye, where the delimiters are the double quote mark ("), the single quote mark ('), the period (.), and the at sign (@).

     \ch "hi" "bye"
     \ch 'hi' 'bye'
     \ch .hi. .bye.
     \ch @hi@ @bye@

Throughout this document, we use the double quote mark as the delimiter unless there is some reason to do otherwise.

Change tables follow these conventions:

 1. Any characters (other than the delimiter) may be placed between the match and substitution strings.  This allows various notations to symbolize the change.  For example, the following are equivalent:

          \ch "thou" "you"
          \ch "thou" to "you"
          \ch "thou" > "you"
          \ch "thou" --> "you"
          \ch "thou" becomes "you"

 2. Comments included after the substitution string are initiated by a designated character such as a semicolon (;). The following lines illustrate the use of comments:

          \ch "qeki" "qiki" ; for cases like wawqeki
          \ch "thou" "you"  ; for modern English

 3. A change can be ignored temporarily by turning it into a comment field. This is done either by placing an unrecognized field code in front of the normal \ch, or by placing the comment character (;) in front of it.  For example, only the first of the following three lines would effect a change:

          \ch "nb" "mp"
          \no \ch "np" "np"
          ;\ch "mb" "nb"

The changes in the text output control file are applied as an ordered set of changes.  The first change is applied to the entire word by searching from left to right for any matching strings and, upon finding any, replacing them with the substitution string.  After the first change has been applied to the entire word, then the next change is applied, and so on.  Thus, each change applies to the result of all prior changes.  When all the changes have been applied, the resulting word is returned.  For example, suppose we have the following changes:

     \ch "aib" > "ayb"
     \ch "yb"  > "yp"

Consider the effect these have on the word paiba.  The first changes i to y, yielding payba; the second changes b to p, to yield paypa.  (This would be better than the single change of aib to ayp if there were sources of yb other than the output of the first rule.)

The way in which change tables are applied allows certain tricks.  For example, suppose that for Quechua, we wish to change hw to f, so that hwista becomes fista and hwis becomes fis.  However, we do not wish to change the sequence shw or chw to sf or cf (respectively).  This could be done by the following sequence of changes. (Note, @ and $ are not otherwise used in the orthography.)

     \ch "shw" > "@"     ; (1)
     \ch "chw" > "$"      ; (2)
     \ch "hw"  > "f"      ; (3)
     \ch "@"   > "shw"   ; (4)
     \ch "$"   > "chw"    ; (5)

Lines (1) and (2) protect the sh and ch by changing them to distinguished symbols.  This clears the way for the change of hw to f in (3).  Then lines (4) and (5) restore @ and $ to sh and ch, respectively. (An alternative, simpler way to do this is discussed in the next section.)

Environmentally constrained changes
-----------------------------------

It is possible to impose string environment constraints (SECs) on changes in the orthography change tables.  The syntax of SECs is described in detail in section.

For example, suppose we wish to change the mid vowels (e and o) to high vowels (i and u respectively) immediately before and after q.  This could be done with the following changes:

     \ch "o" "u"  / _ q  / q _
     \ch "e" "i"  / _ q  / q _

This is not entirely a hypothetical example; some Quechua practical orthographies write the mid vowels e and o.  However, in the environment of /q/ these could be considered phonemically high vowels /i/ and /u/.  Changing the mid vowels to high upon loading texts has the advantage thatemdashfor cases like upun ``he drinks'' and upoq ``the one who drinks''emdashthe root needs to be represented internally only as upu ``drink''.  But note, because of Spanish loans, it is not possible to change all cases of e to i and o to u.  The changes must be conditioned.

In reality, the regressive vowel-lowering effect of /q/ can pass over various intervening consonants, including /y/, /w/, /l/, /ll/, /r/, /m/, /n/, and /n/.  For example, /ullq/ becomes ollq, /irq/ becomes erq, and so on.  Rather than list each of these cases as a separate constraint, it is convenient to define a class (which we label +resonant) and use this class to simplify the SEC.  Note that the string class must be defined (with the \scl field code) before it is used in a constraint.

     \scl +resonant y w l ll r m n n~
     \ch "o" "u" / q _ / _ ([+resonant]) q
     \ch "e" "i" / q _ / _ ([+resonant]) q

This says that the mid vowels become high vowels after /q/ and before /q/, possibly with an intervening /y/, /w/, /l/, /ll/, /r/, /m/, /n/, or /n/.

Consider the problem posed for Quechua in the previous section, that of changing hw to f.  An alternative is to condition the change so that it does not apply adjacent to a member of the string class Affric which contains s and c.

     \scl Affric c s
     \ch "hw" "f" / [Affric] ~_

It is sometimes convenient to make certain changes only at word boundaries, that is, to change a sequence of characters only if they initiate or terminate the word.  This conditioning is easily expressed, as shown in the following examples.

     \ch "this" "that"           ; anywhere in the word
     \ch "this" "that"  / # _    ; only if word initial
     \ch "this" "that"  /   _ #  ; only if word final
     \ch "this" "that"  / # _ #  ; only if entire word

Using text orthography changes
------------------------------

The purpose of orthography change is to convert text from an external orthography to an internal representation more suitable for morphological analysis.  In many cases this is unnecessary, the practical orthography being completely adequate as the internal representation.  In other cases, the practical orthography is an inconvenience that can be circumvented by converting to a more phonemic representation.

Let us take a simple example from Latin.  In the Latin orthography, the nominative singular masculine of the word ``king'' is rex. However, phonemically, this is really /reks/; /rek/ is the root meaning king and the /s/ is an inflectional suffix.  If the program is to recover such an analysis, then it is necessary to convert the x of the external, practical orthography into ks internally.  This can be done by including the following orthography change in the text output control file:

     \ch  "x"  "ks"

In this, x is the match string and ks is the substitution string, as discussed in section.  Whenever x is found, ks is substituted for it.

Let us consider next an example from Huallaga Quechua.  The practical orthography currently represents long vowels by doubling the vowel. For example, what is written as kaa is /ka:/ ``I am'', where the length (represented by a colon) is the morpheme meaning ``first person subject''.  Other examples, such as upoo /upu:/ ``I drink'' and upichee /upi-chi-:/ ``I extinguish'', motivate us to convert all long vowels into a vowel followed by a colon.  The following changes do this:

     \ch  "aa"  "a:"
     \ch  "ee"  "i:"
     \ch  "ii"  "i:"
     \ch  "oo"  "u:"
     \ch  "uu"  "u:"

Note that the long high vowels (i and u) have become mid vowels (e and o respectively); consequently, the vowel in the substitution string is not necessarily the same as that of the match string.  What is the utility of these changes?  In the lexicon, the morphemes can be represented in their phonemic forms; they do not have to be represented in all their orthographic variants.  For example, the first person subject morpheme can be represented simply as a colon (-:), rather than as -a in cases like kaa, as -o in cases like qoo, and as -e as in cases like upichee. Further, the verb ``drink'' can be represented as upu and the causative suffix (in upichee) can be represented as -chi; these are the forms these morphemes have in other (nonlowered) environments. As the next example, let us suppose that we are analyzing Spanish, and that we wish to work internally with k rather than c (before a, o, and u) and qu (before i and e). (Of course, this is probably not the only change we would want to make.) Consider the following changes:

     \ch  "ca"  "ka"
     \ch  "co"  "ko"
     \ch  "cu"  "ku"
     \ch  "qu"  "k"

The first three handle c and the last handles qu.  By virtue of including the vowel after c, we avoid changing ch to kh. There are other ways to achieve the same effect.  One way exploits the fact that each change is applied to the output of all previous changes. Thus, we could first protect ch by changing it to some distinguished character (say @), then changing c to k, and then restoring @ to ch:

     \ch  "ch"  "@"
     \ch  "c"  "k"
     \ch  "@"  "ch"
     \ch  "qu"  "k"

Another approach conditions the change by the adjacent characters.  The changes could be rewritten as

     \ch  "c"  "k"  / _a  / _o  / _u  ; only before a, o, or u
     \ch  "qu"  "k"                   ; in all cases

The first change says, ``change c to k when followed by a, o, or u.''  (This would, for example, change como to komo, but would not affect chal.)  The syntax of such conditions is exactly that used in string environment constraints; see section.

Where orthography changes apply
-------------------------------

Input orthography changes are made when the text being processed may be written in a practical orthography.  Rather than requiring that it be converted as a prerequisite to running the program, it is possible to have the program convert the orthography as it loads and before it processes each word.

The changes loaded from the text output control file are applied after all the text is converted to lower case (and the information about upper and lower case, along with information about format marking, punctuation and white space, has been put to one side.)  Consequently, the match strings of these orthography changes should be all lower case; any change that has an uppercase character in the match string will never apply.

A sample orthography change table
---------------------------------

We include here the entire orthography input change table for Caquinte (a language of Peru).  There are basically four changes that need to be made: (1) nasals, which in the practical orthography reflect their assimilation to the point of articulation of a following noncontinuant, must be changed into an unspecified nasal, represented by N; (2) c and qu are changed to k; (3) j is changed to h; and (4) gu is changed to g before i and e.

     \ch  "mp"  "Np"     ; for unspecified nasals
     \ch  "nch" "Nch"
     \ch  "nc"  "Nk"
     \ch  "nqu" "Nk"
     \ch  "nt"  "Nt"

     \ch  "ch"  "@"     ; to protect ch
     \ch  "c"   "k"      ; other c's to k
     \ch  "@"   "ch"    ; to restore ch
     \ch  "qu"  "k"

     \ch  "j"   "h"

     \ch  "gue" "ge"
     \ch  "gui" "gi"

This change table can be simplified by the judicious use of string environment constraints:

     \ch  "m"  >  "N"  / _p
     \ch  "n"  >  "N"  / _c  / _t  / _qu

     \ch  "c"  >  "k"  / _~h
     \ch  "qu" >  "k"

     \ch  "j"  >  "h"

     \ch  "gu" >  "g"  / _e  /_i

As suggested by the preceding examples, the text orthography change table is composed of all the \ch fields found in the text output control file.  These may appear anywhere in the file relative to the other fields.  It is recommended that all the orthography changes be placed together in one section of the text output control file, rather than being mixed in with other fields.

Syntax of Orthography Changes
-----------------------------

This section presents a grammatical description of the syntax of orthography changes in BNF notation.

      1a. <orthochange>  ::= <basic_change>
      1b.                    <basic_change> <constraints>

      2a. <basic_change> ::= <quote><quote> <quote><string><quote>
      2b.                    <quote><string><quote> <quote><quote>
      2c.                    <quote><string><quote> <quote><string><quote>

      3.  <quote>        ::= any printing character not used in either
                             the ``from'' string or the ``to'' string

      4.  <string>       ::= one or more characters other than the quote
                             character used by this orthography change

      5a. <constraints>  ::= <change_envir>
      5b.                    <change_envir> <constraints>

      6a. <change_envir> ::= <marker> <leftside> <envbar> <rightside>
      6b.                    <marker> <leftside> <envbar>
      6c.                    <marker> <envbar> <rightside>

      7a. <leftside>   ::= <side>
      7b.                  <boundary>
      7c.                  <boundary> <side>

      8a. <rightside>  ::= <side>
      8b.                  <boundary>
      8c.                  <side> <boundary>

      9a. <side>       ::= <item>
      9b.                  <item> <side>
      9c.                  <item> ... <side>

     10a. <item>       ::= <piece>
     10b.                  ( <piece> )

     11a. <piece>      ::= ~ <piece>
     11b.                  <literal>
     11c.                  [ <literal> ]

     12.  <marker>     ::= /
                           +/

     13.  <envbar>     ::= _
                           ~_

     14.  <boundary>   ::= #
                           ~#

     15.  <literal>    ::= one or more contiguous characters

Comments on selected BNF rules
..............................

2.
     The same <quote> character must be used at both the beginning and the end of both the ``from'' string and the ``to'' string.

3.
     The double quote (") and single quote (') characters are most often used.

7-8.
     Note that what can appear to the left of the environment bar is a mirror image of what can appear to the right.

9c.
     An ellipsis (...) indicates a possible break in contiguity.

10b.
     Something enclosed in parentheses is optional.

11a.
     A tilde (~) reverses the desirability of an element, causing the constraint to fail if it is found rather than fail if it is not found.

11c.
     A literal enclosed in square brackets must be the name of a string class defined by a \scl field in the analysis data file, or earlier in the dictionary orthography change file.

12.
     A +/ is usually used for morpheme environment constraints, but may used for change environment constraints in \ch fields in the dictionary orthography change table file.

13.
     A tilde attached to the environment bar (~_) inverts the sense of the constraint as a whole.

14b.
     The boundary marker preceded by a tilde (~#) indicates that it must not be a word boundary.

15.
     The special characters used by environment constraints can be included in a literal only if they are immediately preceded by a backslash:

          \+  \/  \#  \~  \[  \]  \(  \)  \.  \_  \\