TWiki> KitWiki Web>FinnishActivities>HfstHome>HfstDevelopmentAPIDocumentation>HfstAPITransducerLayerOLD (2009-09-30, ErikAxelson) EditAttach

This document deals with the datatypes related to transducer calculus and support. This layer is depends on HfstAPIFundamentalKeyLayerOLD.

Contents:

Name of the type | Comment | hfst-lexc | hfst-twolc |
---|---|---|---|

TransducerHandle |
A finite-state transducer | Y | Y |

Type | Function | Comment | hfst-lexc | hfst-twolc |
---|---|---|---|---|

TransducerHandle |
`create_empty_transducer` () |
Make an empty transducer. | Y | Y |

TransducerHandle |
`create_epsilon_transducer` () |
Make an epsilon transducer. | Y | Y |

TransducerHandle |
`define_transducer` (KeyPair p) |
Make a transducer that accepts one occurrence of key pair p. | Y | Y |

TransducerHandle |
`define_pi_transducer` (KeyPairSet Pi) |
Make a transducer that accepts the union of the key pairs in a set Pi. | Y | Y |

TransducerHandle |
`add_weight` (TransducerHandle t, float w) |
Add weight w to transducer t. Note: Does nothing if the underlying library is does not support weights. |
Y | N |

KeyPairSet |
`define_keypair_set` (TransducerHandle t) |
Define a set of pairs by collecting all key pairs in transducer t. | Y | N |

void |
`delete_transducer` (TransducerHandle t) |
Delete transducer t. | Y | Y |

**Note.** The current API is biased towards numerical weights.

- The first kind of operations treat KeyPairs as atomic transition labels. The key for epsilon is treated as if it were a normal symbol.
- The second kind of operations interpret the input and output keys in key pairs as strings. Therefore the input side of pair
`0:a`

is the empty string '' and the identity relation of the empty string '' composes with relation`0:a`

.^{*}

Type | Function | Comment | hfst-lexc | hfst-twolc |
---|---|---|---|---|

TransducerHandle |
`concatenate` (TransducerHandle t1, TransducerHandle t2) |
Concatenation of t1 and t2. | Y | Y |

TransducerHandle |
`copy` (TransducerHandle t) |
A deep copy of t. | Y | Y |

TransducerHandle |
`disjunct` (TransducerHandle t1, TransducerHandle t2) |
Disjunction of t1 and t2. | Y | Y |

TransducerHandle |
`disjunct_transducers_as_tries` (TransducerHandle t1, TransducerHandle t2) |
Disjunction of t1 and t2 that are both tries. The resulting transducer is also a trie. | Y | Y |

TransducerHandle |
`intersect` (TransducerHandle t1, TransducerHandle t2) |
Intersection of t1 and t2. | Y | Y |

TransducerHandle |
`insert_freely` (TransducerHandle t, KeyPair p) |
Freely insert key pair p into t. | N | Y |

TransducerHandle |
`negate` (TransducerHandle t, KeyPairSet Pi) |
Complement of t with regard to a set of key pairs Pi. | N | Y |

TransducerHandle |
`optionalize` (TransducerHandle t) |
Disjunction of t and epsilon. | Y | Y |

TransducerHandle |
`repeat_n` (TransducerHandle t, int n) |
Transducer t repeated n times. | Y | Y |

TransducerHandle |
`repeat_le_n` (TransducerHandle t, int n) |
Transducer t repeated at most n times. | N | N |

TransducerHandle |
`repeat_star` (TransducerHandle t) |
Transducer t *. | Y | Y |

TransducerHandle |
`repeat_plus` (TransducerHandle t) |
Transducer t +. | Y | Y |

TransducerHandle |
`shuffle` (TransducerHandle t1, TransducerHandle t2) |
Shuffle of t1 and t2. | N | Y |

TransducerHandle |
`subtract` (TransducerHandle t1, TransducerHandle t2) |
t1 minus t2. | N | Y |

TransducerHandle |
`remove_pair` (TransducerHandle t, KeyPair p) |
Remove transitions whose label is key pair p. | Y | Y |

TransducerHandle |
`remove_pairs` (TransducerHandle t, KeySet ss) |
Remove transitions where a key from ss is used on both the input and output sides. | Y | Y |

TransducerHandle |
`substitute_with_pair` ( TransducerHandle t, KeyPair p1, KeyPair p2) |
Substitute all transitions with label in p1 with label p2. | Y | |

TransducerHandle |
`substitute_with_transducer` ( TransducerHandle t, KeyPair p, TransducerHandle tr) |
Substitute all transitions in transducer t having label equal to p with transducer tr. | Y | |

TransducerHandle |
`extract_input_language` (TransducerHandle t) |
Extract the input language of t. | Y | Y |

TransducerHandle |
`extract_output_language` (TransducerHandle t) |
Extract the output language of t. | Y | Y |

TransducerHandle |
`add_input_language` (TransducerHandle t, KeyPairSet s) |
Add input language to t using a set of feasible pairs. | N | N |

TransducerHandle |
`add_output_language` (TransducerHandle t, KeyPairSet s) |
Add output language to t using a set of feasible pairs. | N | N |

TransducerHandle |
`compose` (TransducerHandle t1, TransducerHandle t2) |
Composition of t1 and t2. | Y | Y |

TransducerHandle |
`invert` (TransducerHandle t) |
Switch input and output in the pairs of transducer t. | N | Y |

TransducerHandle |
`reverse` (TransducerHandle t) |
Reverse transducer t. | N | N |

Type | Function | Comment | hfst-lexc | hfst-twolc |
---|---|---|---|---|

TransducerHandle |
`determinize` (TransducerHandle t) |
Determinize transducer t. | Y | Y |

TransducerHandle |
`minimize` (TransducerHandle t) |
Minimize transducer t. | Y | Y |

TransducerHandle |
`push_weights` (TransducerHandle t, bool initial) |
Push the weigths in transducer t towards the initial state, if initial is true, othewise towards the final state. | Y | N |

TransducerHandle |
`remove_epsilons` (TransducerHandle t) |
Remove transitions where epsilon occurs as both input and output keys. | Y | Y |

TransducerHandle |
`find_best_paths` (TransducerHandle t, int n, bool unique=false) |
Collect n best paths of transducer t. If unique is requested, equal paths are collected only once. | N | N |

bool |
`is_automaton` (TransducerHandle t) |
Whether for every arc in t input label is the same as output label. | Y | N |

bool |
`is_cyclic` (TransducerHandle t) |
Whether t is cyclic. | Y | N |

bool |
`is_deterministic` (TransducerHandle t) |
Whether t is deterministic. | N | N |

bool |
`is_empty` (TransducerHandle t) |
Whether t is the empty transducer. | Y | Y |

bool |
`is_epsilon` (TransducerHandle t) |
Whether t is the epsilon transducer. | Y | N |

bool |
`is_minimal` (TransducerHandle t) |
Whether t is a minimal transducer. | Y | N |

bool |
`is_subset` (TransducerHandle t2, TransducerHandle t2) |
Whether t1 is a subset of t2. | N | N |

bool |
`are_equivalent` (TransducerHandle t1, TransducerHandle t2) |
Whether t1 and t2 are equivalent. | Y | Y |

bool |
`are_disjoint` (TransducerHandle t2, TransducerHandle t2) |
Whether t1 and t2 have an empty intersection. | N | N |

float |
`get_weight` (TransducerHandle t) |
Get the total weight of one-path transducer t. Note: Returns zero if the underlying library does not support weights. |
Y | N |

Type | Function | Comment | hfst-lexc | hfst-twolc |
---|---|---|---|---|

int |
`read_format` (istream &is=cin) |
Read the format of the next transducer in the input stream is. | Y | N |

TransducerHandle |
`read_transducer` (istream &is=cin) |
Read transducer in binary form from input stream is. The transducer is assumed not to have an alphabet, so the keys will be used directly for further processing and no harmonizing is needed. | Y | N |

TransducerHandle |
`read_transducer` (char *filename) |
Read a binary transducer from file filename. The transducer is assumed to have no explicit alphabet, so no harmonization is needed. | N | N |

void |
`write_transducer` (TransducerHandle t, ostream &os=cout) |
Write t in binary form to output stream os without storing the alphabet. | Y | Y |

void |
`write_transducer` (TransducerHandle t, char *filename) |
Write transducer t to file filename without storing the alphabet. | N | Y |

-- KristerLinden - 01 Oct 2008 et al. ... -- AnssiYliJyra - 16 Oct 2008 et al.

Topic revision: r15 - 2009-09-30 - ErikAxelson

**TWiki Reference**

- ATasteOfTWiki
- TextFormattingRules
- TWikiVariables
- FormattedSearch
- TWikiDocGraphics
- InstalledPlugins
- TWikiReferenceManual

Copyright © 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

Ideas, requests, problems regarding TWiki? Send feedback