The Emu Script Library

The emu-script package is a collection of tcl procedures provided to make writing automatic hierarchy building scripts (the section called AutoBuild Scripts) easier. The package will grow as new procedures are contributed by Emu users. To use these procedures in a script include the line:
package require emu-script
    
at the beginning of your script file. The remainder of this section describes the individual procedures made available by this package.

MapLevels

The MapLevels procedure can be used to generate segments (or events) at a parent level from those on a child level using a set of context free rewrite rules to describe the mapping. For example, assume that you have hand labelled Phonetic level segments including detail such as the stop burst [p] and following aspiration [H] and wish to construct a hierarchy fragment where these two Phonetic segments are dominated by a single /p/ phoneme. The mapping between these levels could be described in the following rewrite rule:
p H -> p
     
The MapLevels procedure takes a set of rules like this and constructs new segments at the parent level (the Phoneme level in this example) linking them to the appropriate children at the child level (the Phonetic level).

The format of the rules understood by MapLevels is as follows. The left hand side of the rule consists of one or more labels or variables. A label must match the label of a segment exactly for the rule to be applied. A variable has two alternate forms. The form <name> matches any segment label. The form <name=category1,category2>, where the category names (there may be one or more of these, separated by commas with no intervening space characters) correspond to those defined in legal label statements in the database template (the section called Legal Label Definitions in Chapter 4), matches only labels in all of these categories. The right hand side of the rule consists of one or more labels or variables; in this case the variables must have appeared on the left hand side of this rule. The effect of a rule is to create new segments corresponding to the right hand side labels at the parent level and link them to all of the segments which matched the left hand side labels.

As an example the following rule uses a variable to match any stop segment at the Phonetic level followed by aspiration and rewrites it to a Phoneme segment with the same stop label. It is a more general form of the example rule given above.
<s=stop> H -> <s>     
the variable <s=stop> will only match segment labels which have been defined as stops in a legal label statement in the template (the section called Legal Label Definitions in Chapter 4). If the template contained the following line:
legal Phonetic stop p t k b d g
then the above rule would match any of the sequences [p H] [t H] [k H] [b H] [d H] or [g H]. The rule would then create a new segment at the Phoneme level with a label corresponding to whichever stop was matched by the left hand side of the rule.

To use MapLevels you must first read the rules from a file using the ReadLevelRules procedure:

ReadLevelRules filename

The filename argument is the name of the file to read, and returns a structure representing the rules which can then be passed to the MapLevels procedure.

The MapLevels procedure takes five arguments:

MapLevels template hierarchy parent-level child-level ruleset

The template is the relevant database template (the name of the template command as defined by a call to emutemplate), hierarchy is the current hierarchy which is to be modified (the name of the hierarchy command as returned by the hierarchy template subcommand). parent-level and child-level are the names of the two levels to be mapped -- segments must already exist on the child level and the parent level must dominate the child level in the database template. Finally ruleset is the ruleset structure returned by ReadLevelRules.

The result of running MapLevels is to rewrite any of the child level segments into parent level segments according to the rules specified. If no rule matches a particular segment label, then if that label is defined as being a legal label at the parent level, it will be mapped onto a single segment at the parent level. For example if there is no rule matching [A] segments, and if /A/ is defined as a legal Phoneme level segment label, then the MapLevels procedure will create a new segment at the Phoneme level with the label /A/ and link it to the Phonetic [A] segment. If the label is not legal at the parent level, the script will raise an error. A consequence of this default behaviour is that the legal label definitions in the database template should be complete for both parent and child levels.

An example of the use of MapLevels is as follows. The file C:\Emu\myp2prules.txt contains the following rule definitions:
# Phonetic to Phoneme rules for Aus English, using ANDOSL scheme

# Aspirated stops
<s=stop> H -> <s>

Or r -> r
Om m -> m

rr -> r

\# -> {}
-- note the use of the hash character to introduce comments in rule files. These rules can be applied in an AutoBuild script as follows:
proc AutoBuildInit {template} {
      global rules
      set rules [ReadLevelRules C:\\Emu\\myp2prules.txt]
}

proc AutoBuild {template hierarchy} {
      global rules

      MapLevels $template $hierarchy Phoneme Phonetic $rules
}

This procedure has so far mainly been used to map Phonetic onto Phoneme level descriptions. It is not limited to this mapping however and any mapping which can be expressed by rule can be implemented this way. For example here is a ruleset which might be used to map Phonemes onto words in a database with only a small word set:
k A t -> cat
d O g -> dog
m A n -> man

LinkFromTimes

Links events or segments on a child level to the parent segments in which they are contained.

Syllabify

Segment phonemes into syllables using the maximum onset principle.