


SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



NAME
     sml - speech measurement language interpreter

SYNOPSIS
     sml (-I) (-s|-S) (-c|-C) (-t|-T) (-r)  (-f)  (-i  item)  (-d
     dic) program (datafile(s))

DESCRIPTION
     sml is the interpreter for a programming language called SML
     which is described below. sml takes the source of a SML pro-
     gram, compiles it to an intermediate code  and  executes  it
     against a given list of database files (which may be empty).
     The name of a directory containing  datafiles  may  be  used
     instead  of  a  datafile,  in which case the contents of the
     directory are (recursively) extracted.

     Options and their meanings are:

     -I         Identify interpreter and exit.

     -s|-S      Dump symbol table after  compilation.  "-s"=part,
                "-S"=full.

     -c|-C      Dump intermediate code  after  compilation.  "-c"
                dumps source and code, "-C" dumps code only.

     -t|-T      Trace  mode.   Detail  program  execution.   "-t"
                traces  execution  of source.  "-T" traces execu-
                tion of source and intermediate code.

     -r         Report run-time  statistics  after  execution  of
                program.

     -f         Disable file check reporting.  File  checking  is
                still carried out, but the names of non-datafiles
                are not reported.

     -iitem     Select input item numbers.  These become  initial
                defaults, they may be overridden by "select", see
                below.

     -ddic      Use file dic instead of the default phonetic dic-
                tionary

LEXICAL ITEMS
     Lexical items in SML are reserved  words,  functions,  vari-
     ables,  numbers,  strings or punctuation. Reserved words are
     those used in the syntax of the language,  described  below.
     Functions  are  either  user-defined  or  built  in  to  the
     language and described in two sections below.  Variables and
     function  names  are sequences of alphanumeric characters of
     any length, with a leading alphabetic character.   Case  may



SFS                     Last change: UCL                        1






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



     be  used to distinguish variables and function names. Built-
     in names may be used as variables, but access to  the  func-
     tion  is lost.  Numbers may be represented as a digit string
     in standard integer, floating point  or  exponential  format
     (e.g. -2, 0.0023, 1.223E-1). Strings are sequences of print-
     able characters enclosed in double quotes.  The  usual  con-
     ventions  for "escaped" sequences may be used to obtain new-
     line, tab, double quote, etc within a string.

OPERATORS
     Arithmetic  operators  are:  "+",  "-",  "*",  "/"  and  "%"
     (modulus) with usual precedence.

     Boolean operators are "==", "!=",  "<",  "<=",  ">=",  "&&",
     "||" and "!".

     String operators are "++" (concatenate) , ">>" (special con-
     catenate)  and  for  editing  strings: <string>:<width>, and
     <string>:<start>:<end>.  Thus:
          "abc" ++ "def" -> "abcdef"
          "abc" >> "def" -> "abc>>def"
          "abcdef":2     -> "ab"
          "abcdef":8     -> "abcdef  "
          "abcdef":-2    -> "ef"
          "abcdef":-8    -> "  abcdef"
          "abcdef":2:4   -> "bcd"

     Parentheses may be  used  to  change  order  of  arithmetic,
     boolean or string operator evaluation.

EXPRESSION EVALUATION
     Every simple variable or arithmetic expression evaluates  to
     a  floating point number or to a special ERROR value.  ERROR
     values propagate through  expressions,  so  that  an  entire
     expression  evaluates  to  ERROR  if  any  of its components
     evaluates to ERROR.  Arithmetic functions return ERROR  when
     they cannot satisfy a given request (e.g. sqrt(-1)).  Arith-
     metic functions can be used as  statements,  in  which  case
     they cause a run-time error if they return ERROR.

     Conditional expressions return one of  three  values:  TRUE,
     FALSE or ERROR.  A conditional expression evaluates to ERROR
     if any of its components evaluates to error.  An  arithmetic
     expression may be used as a conditional expression, in which
     case it evaluates to  FALSE  if  the  arithmetic  expression
     evaluates to ERROR, and TRUE otherwise.

     String functions return the string "E=R=R=O=R" in case of  a
     fault.   Functions  that  take  string  arguments and return
     numeric values  return  ERROR  if  suppied  with  the  error
     string.




SFS                     Last change: UCL                        2






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



PROCEDURAL STRUCTURE
     A SML program consists of up to three procedures, the  first
     called "init", the second "main" and the third "summary".  A
     typical schema is:

               Global_declarations
               Function_declarations
               Global_declarations
               init {
                    Local_declarations
                    Statements
               }
               Global_declarations
               main {
                    Local_declarations
                    Statements
               }
               Global_declarations
               summary {
                    Local_declarations
                    Statements
               }

     The statements in the "init" procedure  are  executed  once,
     before any database file is accessed.  The statements in the
     "main" procedure are executed once per database file on  the
     command  line (zero times if no files given). The statements
     in "summary" are executed once, after all the database files
     have  been accessed.  Variable declarations may be made out-
     side the procedures, in which case  they  are  available  to
     subsequent  procedures,  or  they  may be made within a pro-
     cedure, in which case they are only available for use within
     that  procedure.  Before  any of the three procedures, func-
     tions may be defined.  Functions accept parameters by  value
     or  by  address  and  may  utilise both static and automatic
     storage for local variables.

VARIABLE DECLARATION
     There are four kinds of variables: var or simple  variables,
     stat  or  statistics  variables,  string or character string
     variables, and file or file i/o variables.  Statistics vari-
     ables  have  six  "internal"  fields  that are automatically
     updated during use, see list below.  These  internal  values
     are accessed by <variable name>.<field name>, but may not be
     directly assigned to.  Variables and arrays of variables are
     declared as in the following example:

               var incount,targets[1:10]
               stat tardist,dists[1:100]
               string sys,names[5:20]
               file op




SFS                     Last change: UCL                        3






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



     The upper and lower bounds of arrays must  be  declared  and
     are  fixed.  Arrays of file and local file variables are not
     allowed.  File variables must be  associated  with  external
     files  or  pipelines using the functions "openin", "openout"
     or "openappend" before they may be used in  print  or  input
     statements.   Functions  may only return var or string vari-
     ables.  All variables are automatically initialised to  zero
     or "".

STATEMENTS
     Assignment statements are of the form:

               var_variable    =  expression
               stat_variable   += expression
               string_variable =  string_expression

     In the first case, the expression is evaluated and  assigned
     to  the variable on the left-hand-side.  In the second case,
     the internal fields of the statistics variable  are  updated
     with  the value of the expression (no change if evaluates to
     ERROR).  In the third case, the string  expression  replaces
     the existing contents of the string variable.

     Conditional statements are of the form:

               if (conditional_expression) statement
         or
               if (conditional_expression) statement else statement

     Where "statement" may be a compound statement (statements in
     braces).   In  the  first case, the statement is executed if
     the conditional expression evaluates to TRUE.  In the second
     case,  the  first  statement  is executed if the conditional
     expression evaluates to TRUE, the second if it evaluates  to
     FALSE, and neither if it evaluates to ERROR.

     While statements are of the form:

               while (conditional_expression) statement

     Where "statement" is executed for as long as the conditional
     expression evaluates to TRUE.

     For statements are of the form:

               for (statement-A;conditional_expression;statement-B) statement-C

     This is equivalent to

               statement-A
               while (conditional_expression) {
                    statement-C



SFS                     Last change: UCL                        4






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                    statement-B
               }


     Switch statements are of the form:

               switch (expression) {
                    case_matches
               }

     where "expression" can be arithmetic or  string,  and  where
     "case matches" are from:

               case NUMBER : statement
         or
               case STRING : statement
         or
               pattern STRING : statement
         or
               range NUMBER : NUMBER : statement
         or
               default : statement

     Matches are always performed in the order specified  -  thus
     the  default case must always come last.  The "pattern" type
     matches with a regular expression.  The "range" type matches
     with a numeric range (inclusive lower bound, exclusive upper
     bound).  The "statement" block is  executed  for  the  first
     match found.

     With statements are of the form:

               with (pattern_string) statement
         or
               withn (pattern_string , count) statement
         or
               within (start_time , end_time) statement

     These are procedural devices that restrict the timerange  of
     pattern  matching functions (described below) within "state-
     ment". The first type restricts matching to the time  domain
     of  the  annotation(s) matching a given pattern.  The second
     type restricts matching to the  time  domain  of  the  count
     annotation  match.   The  third  type  restricts matching to
     within two given times.  See description of pattern matching
     below.   If  the  time range evaluates to ERROR then 'state-
     ment' is not executed.

     There is a loop "break" statement of the form

               break




SFS                     Last change: UCL                        5






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



     which if executed within a "for" or "while" loop immediately
     exits  to  the next most nested level.  If not executed in a
     loop  construct,  "break"  terminates  the  program  (inside
     'init' and 'summary') or skips the current data file (inside
     'main').

     Print statements are of the form:

               print print_list
         or
               print # file_variable print_list

     The  first  type  sends  output  to  the  standard   output.
     "print_list"  is  a  sequence  of  expressions  and  strings
     separated by commas.  Printable items have a  default  field
     width which may be changed using:

               <expression> : <field_width>
         or
               <expression> : <field_width> : <fraction_length>
         or
               <string> : <field_width>
         or
               <string> : <start> : <end>

     For strings, the field width manipulations are really string
     editing operations.

     Input statements are of the form:

               input input_list
         or
               input # file_variable input_list
         or
               inputline string_variable
         or
               inputline # file_variable string_variable

     Where "input_list" is a sequence of var variables  separated
     by  commas  or  a  single string variable.  Numbers are ter-
     minated in the input by whitespace, strings by [RETURN].

     There are two built in procedures:

     clear(variable)     resets  variables  or  arrays  to  zero,
                         empty or null, as appropriate.

     abort(string_expression)
                         halts program execution with given  mes-
                         sage.





SFS                     Last change: UCL                        6






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



     For debugging purposes there are the statements traceon  and
     traceoff  which enable source-line tracing of program execu-
     tion of the bracketed lines.

USER-DEFINED FUNCTIONS
     Users may define functions at the beginning of each  program
     (before init). The structure of a function definition is:

               function type name (parameters)
               address_parameters
               static_local_variables
               {
                    value_parameters
                    automatic_local_variables
                    statements
               }

     Where "type" is one of var or  string,  and  "name"  is  the
     unique  name  given to the function.  The "parameters" are a
     list of dummy identifiers separated by commas.  The type and
     access  method  of  the  parameters is given in the sections
     "address parameters" and "value parameters".  The first sec-
     tion  identifies  the  parameters as access by address (i.e.
     changes by the function have effect outside  the  function).
     The  second  section  identifies the parameters as access by
     value (i.e. they are copies of the contents of  the  calling
     parameters).   The  parameters  are  also allocated types in
     these sections.  Arrays are indicated by placing "[]"  after
     the  array  name.   File  variables  are  always accessed by
     address.  Static local variables are variables that may only
     be  accessed from within the function but which retain their
     value from one call of the function to the next.   Automatic
     local  variables  are  variables which are instantiated once
     per call of the  function  -  even  if  the  function  calls
     itself.   Thus  a  complete  function declaration might look
     like:

               function var anal(ar,lo,hi,mn,dv)
               var ar[],mn,dv
               {
                    var lo,hi,i
                    stat st
                    for (i=lo;i<=hi;i=i+1) st += ar[i]
                    mn = st.mean
                    dv = st.stddev
                    return(st.count)
               }

     The return statement returns the bracketed expression to the
     calling function and terminates execution of the subroutine.
     The implementation of functions incorporates type and access
     method checking and full recursion.



SFS                     Last change: UCL                        7






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



     Functions may also be stored in external files and  included
     into the source being compiled.  The mechanism also provides
     for 'library' routines that will be supplied for general use
     in  a  central  repository.  External functions are declared
     using:

               library <function_name>

          e.g.

               library anovar

     The interpreter attempts  to  open  a  file  containing  the
     sources of these functions using the following strategy: for
     a  function  called  <func>,  it  attempts  to  open   files
     "./<func>.s",  "~/sml/<func>.s"  and "/usr/lib/sml/<func>.s"
     in that order.  SML source is then  read  from  these  files
     instead of from the main program source file.  Library files
     may be nested up to 5 deep.

BUILT IN VARIABLES
     system variables
          $filecount      Number of the file currently being examined.
          $filename       Name of the file currently being examined.
          $date           String variable holding current date and time.

     main header strings
          $head_username  owner of current file
          $head_source    source of file
          $head_dbase     name of database
          $head_speaker   name of speaker
          $head_session   description of session
          $head_sessdate  date of session
          $head_token     name of token
          $head_rep       repetition of token

     field names of STAT variables
          count           number of assignments
          sum             sum of assignments
          sumsq           sum of squared assignments
          mean            mean of assignments
          variance        variance of assignments
          stddev          standard deviation of assignments

     file variables
          stdin           standard input
          stdout          standard output
          stderr          standard error

     built in constants
          SP, LX, TX, FX, AN, LP, SY, DI, CO, FM, PC, TR




SFS                     Last change: UCL                        8






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



          ERROR

BUILT IN ARITHMETIC FUNCTIONS
  ANNOTATION
     length(pattern)     returns  length  of  pattern  match   to
                         annotation(s) in seconds or ERROR.

     lengthn(pattern, n) returns length of nth pattern  match  to
                         annotation(s) in seconds or ERROR.

     numberof(pattern)   returns number  of  pattern  matches  to
                         annotation(s).

     time(pattern)       returns time at  which  pattern  matches
                         annotation(s) in seconds or ERROR.

     timen(pattern, n)   returns time of  nth  pattern  match  to
                         annotation(s) in seconds or ERROR.

  ARITHMETIC
     abs(expression)     returns absolute value.

     exp(expression)     returns exponential.

     hibound(array_name) returns upper bound of array.

     lobound(array_name) returns lower bound of array.

     log(expression)     returns natural logarithm.

     sqrt(expression)    returns square root.

     trunc(expression)   returns integer part.

  FILES
     close(file_variable)
                         closes file variable.  Returns ERROR  on
                         failure.

     openappend(file_variable, filename)
                         opens given file on given file  variable
                         for   appending  by  printing.   Returns
                         ERROR on failure.

     openin(file_variable, filename)
                         opens  given  filename  or  pipeline  on
                         given file variable for input. Pipelines
                         are distinguished from files  by  ending
                         with "|". Returns ERROR on failure.

     openout(file_variable, filename)
                         opens  given  filename  or  pipeline  on



SFS                     Last change: UCL                        9






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         given  file variable for printing. Pipe-
                         lines are distinguished  from  files  by
                         beginning  with  "|".  Returns  ERROR on
                         failure.

  ITEMS
     next(item,time)     returns the time of the next "event"  in
                         the  item  after  the time specified, or
                         ERROR.  Can be  used  to  determine  the
                         sampling interval for fixed-frame items,
                         or   individual   frame   lengths    for
                         variable-frame   items.  Called  with  a
                         negative time, will return the  time  of
                         the first frame in the item.

     select(item)        selects the designated item as input for
                         subsequent   operations.    Returns  the
                         number of frames in the selected item or
                         ERROR.   This  routine does not override
                         command line  item  selections  if  item
                         number is given as type only.

     selectmatch(itemspec)
                         selects the first item that matches  the
                         specification  supplied  and returns the
                         item number or ERROR.  The item specifi-
                         cation  is  a  string  expression in the
                         format allowed by itspec(SFS3).  Thus  a
                         call  of  selectmatch("TX")  will return
                         the number of the last TX  item.   Over-
                         rides command line item selections.

     selectnext(item)    selects the next item of the  same  type
                         as   input  for  subsequent  operations.
                         Returns the item number or ERROR  if  no
                         more    items    found.    A   call   of
                         selectnext(TX) will return the number of
                         the  first  TX  item (e.g. 3.01).  Over-
                         rides command line item selections.

  MEASUREMENT
     energy(frequency,time)
                         returns the energy in dB from a  coeffi-
                         cient  item  at  the specified frequency
                         and time.

     f1(time), a1(time), b1(time)
                         returns   frequency,    amplitude    and
                         bandwidth  of  formant 1 from SY item at
                         given time.

     f2(time), a2(time), b2(time)



SFS                     Last change: UCL                       10






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         returns   frequency,    amplitude    and
                         bandwidth  of  formant 2 from SY item at
                         given time.

     f3(time), a3(time), b3(time)
                         returns   frequency,    amplitude    and
                         bandwidth  of  formant 3 from SY item at
                         given time.

     f4(time), a4(time), b4(time)
                         returns   frequency,    amplitude    and
                         bandwidth  of  formant 4 from SY item at
                         given time.

     fm(entry, time)     returns the value of the given entry  in
                         a  raw  formant  estimates  item  at the
                         given time or ERROR. The 'entry' parame-
                         ter  indexes  into the formant record as
                         if it was a simple array,  thus  entry=4
                         would return the "npeaks" value.

     fx(time)            returns fundamental frequency  in  Hertz
                         at given time from FX item.

     lp(attribute_name, time)
                         returns  value  of  given  attribute  at
                         given time from LP item.

     sy(parameter, time) returns  value  of  requested  parameter
                         number,  at  given  time  from  SY item.
                         Parameters  are  numbered   sequentially
                         from  0,  with  0=FX,  3=F1, 4=A1, 5=B1,
                         6=F2, etc.

     tr(time)            returns parameter track value  at  given
                         time from TR item.

     tx(time)            returns excitation period in seconds  at
                         given time from TX item.

  STRING
     ascii(string_expression)
                         returns the ASCII  value  of  the  first
                         character  of  the  string, or ERROR for
                         the ERROR string.

     compare(string_expression, string_expression)
                         returns 0 if strings same, returns -1 if
                         first sorts earlier than second, returns
                         1 if second sorts earlier than first.

     entry(string_expression,string_array)



SFS                     Last change: UCL                       11






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         returns the index of the  entry  in  the
                         string array at which the string expres-
                         sion may be found - or ERROR if  not  in
                         array.

     index(regular_expression, string_expression)
                         returns index of match of  full  regular
                         expression  into  string  or ERROR.  The
                         special concatenation operator ">>"  may
                         be used as an OR between regular expres-
                         sions in the call to index.

     strlen(string_expression)
                         returns the length of the string expres-
                         sion,  zero  for null strings, and ERROR
                         for the error string.

     val(string_expression)
                         returns arithmetic value  of  string  or
                         ERROR.

  UTILITY
     stopwatch (expression)
                         if expression is 0.0, then stopwatch  is
                         reset.   If  expression  not  0.0,  then
                         returns elapsed time  since  last  reset
                         (or system boot time) in seconds.

     system(string_expression)
                         executes the string expression as if  it
                         were a command line.

BUILT IN STRING FUNCTIONS
  ANNOTATION
     match(pattern)      returns   string   holding    text    of
                         annotation(s)  matched  by  pattern,  or
                         ERROR string.

     matchn(pattern, n)  returns string holding text of nth match
                         to  annotation(s)  by  pattern, or ERROR
                         string.

  ITEM
     history(itemtype)   returns  the  history   field   of   the
                         currently  selected  item  of  the given
                         type, or ERROR string.

  STRING
     istr(expression)    returns  string  equivalent  of  integer
                         part of expression, or ERROR string.

     str(expression,field,precision)



SFS                     Last change: UCL                       12






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         returns string expression of real number
                         with  given field width and decimal pre-
                         cision, or ERROR string.

     char(expression)    returns a string containing  the  single
                         character  with  the  ASCII value of the
                         expression, or ERROR string  if  outside
                         ASCII range.

GRAPH PLOTTING
     Facilities for producing simple x-y plots are provided by  a
     number  of  simple procedures.  The graph plotting is imple-
     mented using Device-Independent  Graphics  (see  DIG(3))  so
     that  graphs  may  be  piped  to printing devices, stored in
     files and edited.  Appropriate  graphics  commands  for  the
     executing  terminal are determined automatically.  The func-
     tions are:

     plot(file,graphno,ydata,ynum)
                         produces a simple line graph of an array
                         of numbers, where "file" is a file vari-
                         able     determining     the      output
                         device/channel   for  the  graph  -  use
                         "stdout"  for  the   current   terminal;
                         "graphno"  is  the number of the current
                         graph, facilities are provided for  pro-
                         ducing  a  page containing more than one
                         graph (see below) in which  case  graphs
                         are  numbered  left-to-right and top-to-
                         bottom starting  at  1;  "ydata"  is  an
                         array  of  var  containing  the  y  axis
                         values, and "ynum" is the  number  of  y
                         values.  This routine is all you need to
                         create a graph - the following functions
                         merely  alter  the  default  format.  To
                         plot more than  one  line  on  the  same
                         graph  simply  repeat  the graph number.
                         To plot different graphs with  the  same
                         graph  number,  call plotclear() between
                         plots.

     plottitle(file,string)
                         adds an  overall  title  to  a  page  of
                         graphs,  where  "file"  is  the graphing
                         output device/channel  and  "string"  is
                         the title.

     plotaxes(file,graphno,xmin,xmax,ymin,ymax)
                         draws a specific set of axes,  to  over-
                         ride  the  default  axes  calculation of
                         plot().    "file"    is    the    output
                         device/channel,  "graphno" is the number



SFS                     Last change: UCL                       13






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         of the graph  to  be  plotted,  and  the
                         other values set the minimum and maximum
                         values for the x and y axes.

     plotclear(file)     clears the screen or selects a new  out-
                         put page for a new set of graphs. "file"
                         is the output device/channel.

     plotxdata(xdata,flag)
                         specifies the x co-ordinates to be  used
                         for   plotting  the  y-data  in  plot().
                         There are three  possible  settings  for
                         "flag":
                         flag = 0, xdata[] contains all the
                                   x-coordinates required.
                         flag = 1, xdata[1] is xmin,
                                   xdata[2] is xmax.
                         flag = 2, xdata[1] is xmin,
                                   xdata[2] is stepsize on x axis.
                         The default setting is: x[1]=0,  x[2]=1,
                         flag=2.

     plotparam(string)   provides control over the many  optional
                         graph formats.  "string" is a setting of
                         a  plotting  parameter  in  the   format
                         "<parameter>=<value>",    for    example
                         "box=no" or "horizontal=2".  Values  are
                         maintained  for all future graphs in the
                         program unless  explicitly  reset.   The
                         available parameters are:
                         vertical=<num>      number of graphs
                                             vertically
                         horizontal=<num>    number of graphs
                                             horizontally
                         type=<point/line/hist/histend/histdiv/bar>
                                             type of graph
                         char=<character>    character to plot
                                             points with
                         box=<yes/no>        plot graph in box
                         xzero=<yes/no>      x axis goes to zero
                         yzero=<yes/no>      y axis goes to zero
                         xpos=<top/bottom>   x axis at top/bottom
                         ypos=<left/right>   y axis at left/right
                         xlabel=<top/bottom> x label at top/bottom
                         ylabel=<left/right> y label at left/right
                         xscale=<yes/no>     draw x scale
                         yscale=<yes/no>     draw y scale
                         xlog=<yes/no>       make x axis on
                                             logarithmic scale
                         ylog=<yes/no>       make y axis on
                                             logarithmic scale
                         equal=<yes/no>      make axes equal



SFS                     Last change: UCL                       14






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



                         xtitle=<string>     specify x axis label
                         ytitle=<string>     specify y axis label
                         title=<string>      specify graph title

     plotwait(file)      Waits for a  key-press  or  button-press
                         before  continuing.   Useful if you want
                         to pause between different plots.   Does
                         nothing if output is not directed to the
                         screen.   On  some  systems   there   is
                         interaction between this and normal key-
                         board input, so  only  use  one  or  the
                         other.

     plotend(file)       Closes  down  graphics  after  plotting.
                         This  will  be done automatically at the
                         end of the program anyway, so is only of
                         use for programs that print things after
                         displaying things.

PATTERN MATCHING
     Pattern matching in SML is performed using "regular  expres-
     sions"  -  a  string  of  characters that defines a possible
     match to a simple string.   In  functions  like  "time"  and
     "match"  and  the procedural statement "with" - patterns are
     matched against annotations in the current database file.  A
     sequence  of annotations may be matched by using the special
     string concatenation operator ">>" between  regular  expres-
     sions.   Thus  the  pattern  "[ptk]"  matches any annotation
     starting with "p", "t" or "k", but the pattern "s">>"p">>"l"
     matches three annotations which must begin with "s", "p" and
     "l" respectively.  The  same  effect  occurs  when  ">>"  is
     embedded in the string: "s>>p>>l".

     The rules for forming regular expressions are as follows:

     .    matches any single character.

     $    matches the end of the annotation.

     []   enclose alternative characters (can  use  "-"  to  mean
          "through", as in [a-f] meaning [abcdef]).

     +    exploit previous character match one or more times.

     *    exploit previous character match zero or more times.

     {m}  exploit previous character match m times.

     {m,} exploit previous character match m or more times.

     {m,u}
          exploit previous character match a minimum of m  times,



SFS                     Last change: UCL                       15






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



          but a maximum of u times.

     ()   use to group operand of "+", "*" or "{}" operators.

     characters
          apart from the special  characters  above,  these  must
          match  the string exactly.  To match an annotation con-
          taining the special characters, precede them with "\".

     By default all matches start at the beginning of the annota-
     tion  string.   NOTE  that the function "index" and the case
     match pattern take a full regular expression that is not  so
     constrained.   Use  "^"  to  match  to  the beginning of the
     string in "index" or pattern.

EXAMPLE PROGRAM
     /* example -- find mean slopes fitted to fx contours */
     /* function to do line fitting */
     function var fit(f,num)
     var f[]
     {
          var  num,i
          stat x,y,xy
          for (i=1;i<=num;i=i+1) {
               x += i
               y += f[i]
               xy += i*f[i]
          }
          return((num*xy.sum-x.sum*y.sum)/(num*x.sumsq-x.sum*x.sum))
     }
     /* global data */
     var  freq[1:1000]   /* fundamental frequency contour */
     var  timestep  /* time axis of slope */
     string    annotation     /* annotation to match */
     stat slopes         /* statistics of slopes found */
     /* initialise */
     init {
          timestep=0.01
          annotation="\$NUC" >> "[aeiou]"
     }
     /* main processing */
     main {
          var  i,j,num,end
          if (select(AN) && select(FX)) {
               for (i=1;timen(annotation,i);i=i+1) withn(annotation,i) {
                    num=0
                    end=time(annotation) + length(annotation)
                    for (j=time(".");j<end;j=j+timestep) {
                         num=num+1
                         freq[num]=fx(j)
                    }
                    slopes += fit(freq,num)/timestep



SFS                     Last change: UCL                       16






SML(SFS1)         MISC. REFERENCE MANUAL PAGES          SML(SFS1)



               }
          }
     }
     /* summary processing */
     summary {
          print "Number of matches=",slopes.count:1,"\n"
          print "Mean slope= ",slopes.mean:1
          print " +/- ",slopes.stddev:1:1," Hz/s\n"
     }


FILES
     /usr/sfs/data/phon.dic - default phonetic dictionary

VERSION/AUTHOR
     2.5s - Mark Huckvale







































SFS                     Last change: UCL                       17



