HFST: Transducer Extension Layer API

This document deals with the extension functions to the Transducer API. The functions may or may not become part of the core API at some point.

Transducer Variables

To assist in constructing and manipulating transducers in a finite-state transducer calculus, some operations on variables and agreement variables are defined.

Type Function Comment hfst-lexc hfst-twolc
bool define_transducer_variable (char *name, TransducerHandle t) Define a transducer variable name with the transducer value t. N Y?
TransducerHandle copy_transducer_variable (char *name) Copy the value of the transducer variable name. N Y?
bool def_transducer_agreement_variable (char *name, TransducerHandle t) Define a transducer agreement variable name with transducer value t. N N?
TransducerHandle copy_transducer_agreement_variable (char *name) Copy the transducer of the transducer agreement variable name. N N?

Type Function Comment hfst-lexc hfst-twolc
TransducerHandle expand_agreement_variables (TransducerHandle t) Replace agreement variables in t with all their possible values. N N?
TransducerHandle clean_transducer (TransducerHandle t, bool invert, bool reverse) Expand agreement variables, remove epsilons, push weights towards initial state, determinise and minimise t. Parameter invert defines whether input and output levels are switched, and reverse defines whether the transducer is reversed before processing. N N?

Miscelleanous

Type Function Comment hfst-lexc hfst-twolc
vector < TransducerHandle > find_all_paths (TransducerHandle t, bool unique=false) Retrieve all paths of transducer t. If unique is requested, equal paths are collected only once. N  

Extended functions for composition

Type Function Comment hfst-lexc hfst-twolc
TransducerHandle apply_glc (TransducerHandle t1, TransducerHandle t2) "Generalized lenient composition" where the output of transducer t1 is constrained with the strict preference relation represented by t2. N N
TransducerHandle apply_reverse_glc (TransducerHandle t1, TransducerHandle t2) "Generalized lenient composition" where the input of transducer t1 is constrained with the strict preference relation represented by t2. N N
TransducerHandle apply_bidirectional_glc (TransducerHandle t1, TransducerHandle t2) "Generalized lenient composition" where both tapes of transducer t1 are constrained with the strict preference relation represented by t2. N N
TransducerHandle compose_leniently (TransducerHandle t1, TransducerHandle t2) Lenient composition of t1 and t2. N N

Datatypes for Rules and Contexts

The two-level and replace rules are compiled according to formulas encoded in the corresponding functions.

Speech bubble Because of conflict-resolution, most SFST-style twol functions need to be reimplemented in hfst-twolc.

Types

The context type is provided to facilitate rule construction.

Name of the type Comment hfst-lexc hfst-twolc
ContextsHandle A list of transducer pairs N  

Enumeration types for the two-level and replace rules.

Type Definition Comment hfst-lexc hfst-twolc
enum Repl_Type { repl_left, repl_right, repl_up, repl_down } Different types of replace rules. N  
enum Twol_Type { twol_left, twol_right, twol_both } Different types of two-level rules. N  

Functions

Type Function Comment hfst-lexc hfst-twolc
ContextsHandle make_context (TransducerHandle t1, TransducerHandle t2) ContextsHandle with left context t1 and right context t2. N Y?
ContextsHandle append_context (ContextsHandle c1, ContextsHandle c2) Append Contexts c2 to Contexts c1. N N
TransducerHandle make_rule (TransducerHandle t1, Range *r1, Twol_Type type, Range *r2, TransducerHandle t2, KeyPairSet Pi) A transducer that maps Range r1 to Range r2 in the 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. The alphabet of pairs is defined by the set of key pairs Pi. N N
TransducerHandle make_replace (TransducerHandle t, Repl_Type type, bool optional, KeylPairSet 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 alphabet of pairs is defined by the set of key pairs Pi. N N
TransducerHandle make_replace_in_context (TransducerHandle t, Repl_Type type, ContextsHandle p, bool optional, KeyPairSet Pi) A replace transducer that performs the mapping t in the context p. 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 alphabet of pairs is defined by the set of key pairs Pi. N N
TransducerHandle make_restriction (TransducerHandle t, Twol_Type type, ContextsHandle p, int direction, KeyPairSet Pi) A restriction transducer that performs the mapping t in all contexts of p. 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. The alphabet of pairs is defined by the set of key pairs Pi. N Y?

-- KristerLinden - 07 Oct 2008

Functions Based on HfstAPIGeneralizedRestrictionLayerOLD

Functions That Compile Constraints using GR Rules

In the following, c is an OvertFstHandle used to specify context conditions and x is an TransducerHandle specifying what is often called the center of a rule.

It is assumed that the application has constructed all over FSTs by using VarHandles in appropriate and consistent manner.

Type Function Comment hfst-lexc hfst-twolc
OvertFstPair gr_construct_not (TransducerHandle t) not(t).    
OvertFstPair gr_construct_nowhere (TransducerHandle t) nowhere(t).    
OvertFstPair gr_construct_if_P_then_S (TransducerHandle p, TransducerHandle s) if-P-then-S(p,s) (Kaplan & Kay 1994).    
OvertFstPair gr_construct_if_S_then_P (TransducerHandle p, TransducerHandle s) if-S-then-P(p,s) (Kaplan & Kay 1994).    
OvertFstPair gr_construct_iff_P_S (TransducerHandle p, TransducerHandle s) iff-P-S(p,s) (Kaplan & Kay 1994).    
OvertFstPair gr_construct_center_prohibition (TransducerHandle x, OvertFstHandle c) center prohibition x /<= c (in TWOLC).    
OvertFstPair gr_construct_context_restriction (TransducerHandle x, OvertFstHandle c) context restriction x => c (Koskenniemi 1983).    
OvertFstPair gr_construct_coercion (TransducerHandle x, OvertFstHandle c) coercion x <<= c (Yli-Jyrä & Koskenniemi 2004).    
OvertFstPair gr_construct_output_coercion (TransducerHandle x, OvertFstHandle c) surface coercion x <= c (Koskenniemi 1983).    
OvertFstPair gr_construct_input_coercion (TransducerHandle x, OvertFstHandle c) lexical coercion x <- c (less used).    
OvertFstPair gr_construct_center_presence_requirement (TransducerHandle x, OvertFstHandle c) center presence requirement x <== c (Yli-Jyrä & Koskenniemi 2006).    
OvertFstPair gr_construct_presence_requirement (OvertFstHandle c1, OvertFstHandle c2) presence requirement c1 ==> c2 (Yli-Jyrä & Koskenniemi 2006).    
OvertFstPair gr_construct_output_double_arrow (TransducerHandle x, OvertFstHandle c) double arrow x <=> c (Koskenniemi 1983).    
OvertFstPair gr_construct_input_double_arrow (TransducerHandle x, OvertFstHandle c) double arrow x <-> c that combines a lexical coercion and a context restriction (less used).    
OvertFstPair gr_construct_match_L_R (TransducerHandle l, TransducerHandle d, TransducerHandle r) match-L-R(l,d,r) that says that a left side l (right side r) must always be paired with a right side r (left side l), and separated from that with a center that belongs to d (Yli-Jyrä 2007).    
OvertFstPair gr_construct_bracketing_restriction (TransducerHandle l, TransducerHandle r, TransducerHandle d, TransducerHandle c) bracketing restriction constraint # l __ R # => c according to which (∀ vxy)( v∈l ∧ x∈d ∧ y∈r → x∈d ) (Yli-Jyrä 2003).    

GR-Based Engines for Grammar Systems

The GR Calculus makes is easy to define some complete rule systems with rule application modes and conflict resolutions. The interfaces to the following systems will be added here:

  • Two-Level Grammars
  • Generalized Two-Level Grammars
  • Bracketed Generalized Two-Level Grammars
  • Parallel Replacement and Markup Rules

-- AnssiYliJyra - 13 Oct 2008

Topic revision: r6 - 2009-09-30 - ErikAxelson
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback