Rule Layer


Datatypes for rule functions

enum  Twol_Type { twol_left, twol_right, twol_both }
 Different types of two-level rules. More...
enum  Repl_Type { repl_left, repl_right, repl_up, repl_down }
 Different types of replace rules. More...
typedef contexts_t * ContextsHandle
 A list of transducer pairs.

Rule functions

ContextsHandle make_context (TransducerHandle t1, TransducerHandle t2)
 ContextsHandle with a context pair of left context t1 and right context t2.
ContextsHandle append_context (ContextsHandle c1, ContextsHandle c2)
 Add contexts c2 to contexts c1 and return the updated c1.
TransducerHandle make_rule (TransducerHandle t1, KeyPairSet *mappings, Twol_Type type, TransducerHandle t2, KeyPairSet *Pi)
 A transducer that performs mappings defined in KeyPairSet mappings in context defined by transducers t1 and t2 (t1 precedes and t2 follows). Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. Pi defines the alphabet known to the rule.
TransducerHandle make_replace (TransducerHandle t, Repl_Type type, bool optional, KeyPairSet *Pi)
 A replace transducer that performs the mapping t everywhere. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.
TransducerHandle make_replace_in_context (TransducerHandle t, Repl_Type type, ContextsHandle c, bool optional, KeyPairSet *Pi)
 A replace transducer that performs mapping t in context c. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.
TransducerHandle make_restriction (TransducerHandle t, Twol_Type type, ContextsHandle c, int direction, KeyPairSet *Pi)
 A restriction transducer that performs the mapping t in all contexts of c. Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. direction defines to which direction mapping can be done.
void delete_contexts_handle (ContextsHandle c)
 Delete ContextsHandle c.

Detailed Description

Datatypes and functions for rules and contexts.

Typedef Documentation

A list of transducer pairs.

A transducer pair represents the left and right context in a rule.

Definition at line 46 of file rule-layer.h.


Enumeration Type Documentation

enum Repl_Type

Different types of replace rules.

Use them with functions make_replace and make_replace_in_context. Their meaning is explained in both functions.

Enumerator:
repl_left  Repl_type 'repl_left'
repl_right  Repl_type 'repl_right'
repl_up  Repl_type 'repl_up'
repl_down  Repl_type 'repl_down'

Definition at line 33 of file rule-layer.h.

enum Twol_Type

Different types of two-level rules.

Use these with functions make_rule and make_restriction. Their meaning is explained in both functions.

Enumerator:
twol_left  Twol_Type 'twol_left'
twol_right  Twol_Type 'twol_right'
twol_both  Twol_Type 'twol_both'

Definition at line 21 of file rule-layer.h.


Function Documentation

ContextsHandle append_context ( ContextsHandle  c1,
ContextsHandle  c2 
)

Add contexts c2 to contexts c1 and return the updated c1.

Returns:
contexts c1 after c2 has been added to it.
Postcondition:
c1 and c2 are not deleted.

Definition at line 5573 of file hofst.C.

void delete_contexts_handle ( ContextsHandle  c  ) 

Delete ContextsHandle c.

ContextsHandle c and all transducer pairs listed in c are deleted.

ContextsHandle make_context ( TransducerHandle  t1,
TransducerHandle  t2 
)

ContextsHandle with a context pair of left context t1 and right context t2.

Parameters:
t1 Left context. If NULL, interpreted as an epsilon transducer.
t2 Right context. If NULL, interpreted as an epsilon transducer.
Returns:
A ContextsHandle that points to t1 and t2.
Postcondition:
t1 and t2 are not deleted.

Definition at line 5536 of file hofst.C.

TransducerHandle make_replace ( TransducerHandle  t,
Repl_Type  type,
bool  optional,
KeyPairSet Pi 
)

A replace transducer that performs the mapping t everywhere. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.

The result is equivalent to expression [~[.* PROJ(t) .*] PROJ(t)]* ~[.* PROJ(t) .*], where PROJ(t) is

  • input level projection of t if type is 'repl_up'
  • output level projection of t if type is 'repl_down'

Precondition:
Repl_Type type does not have value 'repl_left' or 'repl_right'.
Parameters:
t A transducer defining the mapping.
type The type of replacement rule, 'repl_up' or 'repl_down'.
optional Whether the replacement becomes optional, i.e. whether the resulting transducer is disjuncted with the pi machine [.*].
Pi The alphabet (set) of key pairs known to the rule
Postcondition:
t is deleted.

Definition at line 5604 of file hofst.C.

TransducerHandle make_replace_in_context ( TransducerHandle  t,
Repl_Type  type,
ContextsHandle  c,
bool  optional,
KeyPairSet Pi 
)

A replace transducer that performs mapping t in context c. Repl_Type type defines whether left and right contexts are matched at the output or input level. optional defines if the mapping is optional.

The value of Repl_Type type defines where matching takes place in the following way:

  • if 'repl_up', left and right contexts are both matched at the output level
  • if 'repl_down', left and right contexts are both matched at the input level
  • if 'repl_left', left context is matched at the output level and right context at the input level
  • if 'repl_right', left context is matched at the input level and right context at the output level

For example (from Karttunen 1995) the rule defined by transducer {ab}:x, left context [a b] and right context [a] ('ab' is mapped to 'x' between 'ab' and 'a') yields the following relations when applied to the input string 'abababa' with different Repl_Types:

  Repl_Type:          repl_up                    repl_down                     repl_left          repl_right
                  
  input level:     a b a b a b a     a b a b a b a   or   a b a b a b a      a b a b a b a       a b a b a b a
  output level:    a b  x   x  a     a b  x  a b a        a b a b  x  a      a b a b  x  a       a b  x  a b a

Alphabet definition can affect the way the resulting transducer works. For instance, the rule defined by transducer_ {aa}:{bb}, left context [c] and right context [c] ('aa' is mapped to 'bb' between 'c' and 'c') yields the following relations when applied to the input string 'acaac' with different alphabet definitions:

      Alphabet            input      output(s) 
      
      a, b and c          'acaac'    'acbbc'
      a, b, c and a:b     'acaac'    'acabc', 'acbac', 'acbbc', 'bcabc', 'bcbac', 'bcbbc'

Precondition:
ContextsHandle c includes only one transducer pair (i.e. a maximum of one right and one left context). Left and right context transducers of c are automata, i.e. transducers that map strings onto themselves.
Parameters:
t A transducer defining the mapping.
type The type of replacement rule.
c The context where mapping occurs.
optional Whether the replacement becomes optional, i.e. whether the resulting transducer is disjuncted with the pi machine [.*].
Pi The alphabet (set) of key pairs known to the rule
Postcondition:
t and c are deleted.
More on replace operator in Karttunen: The Replace Operator (1995).

Definition at line 5655 of file hofst.C.

TransducerHandle make_restriction ( TransducerHandle  t,
Twol_Type  type,
ContextsHandle  c,
int  direction,
KeyPairSet Pi 
)

A restriction transducer that performs the mapping t in all contexts of c. Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. direction defines to which direction mapping can be done.

Parameters:
t Transducer defining the mapping.
type The type of mapping rule.
  • if 'twol_left', mapping is obligatory in contexts. Elsewhere the mapping is optional (if the alphabet allows it).
  • if 'twol_right', mapping is optional in contexts. Elsewhere the mapping is not allowed.
  • if 'twol_both', mapping is obligatory in contexts. Elsewhere the mapping is not allowed.
c Contexts where mapping can occur.
direction To which direction mapping can be done.
  • if 0, mapping can be done in both directions
  • if 1, mapping can be done from input to output level
  • if -1, mapping can be done from output to input level
Pi The alphabet (set) of key pairs known to the rule
Postcondition:
t and c are deleted.
More on restriction operator in Yli-Jyra and Koskenniemi: Compiling Contextual Restrictions on Strings into Finite-State Automata (2004).

Definition at line 5940 of file hofst.C.

TransducerHandle make_rule ( TransducerHandle  t1,
KeyPairSet mappings,
Twol_Type  type,
TransducerHandle  t2,
KeyPairSet Pi 
)

A transducer that performs mappings defined in KeyPairSet mappings in context defined by transducers t1 and t2 (t1 precedes and t2 follows). Twol_Type type defines the type of mapping (obligatory/optional/not allowed) in context and elsewhere. Pi defines the alphabet known to the rule.

Parameters:
t1 Left context transducer.
mappings A set of possible key pair mappings that can occur.
type The type of mapping rule.
  • if type is 'twol_left', mapping is obligatory in context. Elsewhere the mapping is optional (if the alphabet allows it).
  • if type is 'twol_right', mapping is optional in context. Elsewhere the mapping is not allowed.
  • if type is 'twol_both', mapping is obligatory in context. Elsewhere the mapping is not allowed.
t2 Right context transducer.
Pi The alphabet (set) of key pairs known to the rule
Postcondition:
t1 and t2 are deleted.
For example, if the alphabet Pi includes symbol pairs a, b, c and a:b, and the function argument values are t1 = [c], mappings = [a:b] and t2 = [c], the resulting transducer yields the following outputs with input string 'acacaca' depending on the value of type:

      type           input        output(s)
      
      'twol_left'    'acacaca'    'acbcbca', 'bcbcbca', 'acbcbcb', 'bcbcbcb' (note that the alphabet must contain the pair a:b here)
      'twol_right'   'acacaca'    'acacaca', 'acbcaca', 'acacbca', 'acbcbca'
      'twol_both'    'acacaca'    'acbcbca' 

More on two-levels rules in Koskenniemi: Two-Level Morphology: A General Computational Model fo Word-Form Recognition and Production (1983).

Definition at line 5852 of file hofst.C.


Generated on Tue Sep 29 11:43:34 2009 for Helsinki Finite-State Transducer Technology (HFST) interface by  doxygen 1.5.8