4.4 Processing the Quasi-Prefix Form

As described in Chapter 2, no semantic interpretation is attached to mathematical content at the recognition step. AS TE R can be enhanced to recognize specialized notation and produce context-sensitive renderings (e.g., speak x2 as “x squared”). Some context-specific processing is needed to produce such renderings, and this section outlines the kind of information that is available: the weight of an object and special patterns.

Measure weight quantifies the complexity of math expressions. The weight function is defined as follows:

  1. The weight of a leaf node with attributes is 1 plus the sum of the weights of its attributes. Attributes are themselves math objects, and their weight is computed recursively.
  2. The weight function on non-leaf nodes is defined recursively:
    weight(m)  =   w-co+ w-ch+ w-at

     w-co  =   weight(contents(m))
     w-ch  =   weight(children(m))
     w-at =   weight(attributes(m))

Recognizing Special Patterns

Recognizing special patterns makes renderings sound more natural. Consider how experienced readers speak math expressions. Even though a+cb is spoken as “the fraction a plus b divided by c”, a2 is spoken as “one half a”. In addition, mathematical notation is inherently ambiguous, with the same notational construct being overloaded to mean different things in different contexts. Thus, the 1’s in x1 and sin1x have different meanings. The recognizer treats both occurrences of the 1 as a visual attribute of the object being superscripted. The decision to treat the 1 appearing as a superscript to the function as denoting the function inverse is made by rendering rules based on special patterns.

Since such interpretation is context sensitive, the quasi-prefix representation is enhanced —before an object is rendered, special-pattern (a memoized7 function) is called to identify special patterns. A user can specify additional patterns by providing method definitions on function special-pattern for specific object types. These special patterns can then be turned on by calling (turn-on-special-pattern <object-name>).

The user can provide rendering rules named <pattern> for object <object>, which get invoked when the particular special pattern is seen. Individual special patterns can be turned off by executing statement (turn-off-special-pattern <object-name>).

All special patterns can be turned off by deactivating style use-special-patterns.

Special patterns built into AS TE R include: