43#include "EST_simplestats.h"
44#include "EST_rw_status.h"
45#include "EST_Option.h"
47#include "EST_TVector.h"
50#define wfst_error_msg(WMESS) (cerr << WMESS << endl,siod_error())
52#define WFST_ERROR_STATE -1
69 { p_weight=t.p_weight; p_state=t.p_state;
70 p_in_symbol = t.p_in_symbol; p_out_symbol=t.p_out_symbol; }
72 { p_weight=w; p_state=s; p_in_symbol=i; p_out_symbol=
o;}
74 float weight()
const {
return p_weight; }
75 int state()
const {
return p_state; }
76 int in_symbol()
const {
return p_in_symbol; }
77 int out_symbol()
const {
return p_out_symbol; }
78 void set_weight(
float f) { p_weight = f; }
79 void set_state(
int s) { p_state = s; }
84enum wfst_state_type {wfst_final, wfst_nonfinal, wfst_error, wfst_licence};
88#define WFST_NONFINAL 1
99 enum wfst_state_type p_type;
112 int name()
const {
return p_name; }
113 int num_transitions()
const {
return transitions.length(); }
114 enum wfst_state_type type()
const {
return p_type; }
115 void set_type(wfst_state_type t) { p_type = t; }
116 void set_tag(
int v) { p_tag = v;}
117 int tag()
const {
return p_tag;}
122enum wfst_mstate_type {wfst_ms_set, wfst_ms_list};
131 enum wfst_mstate_type p_type;
134 { p_name = -1; p_weight = 0.0; p_type = wfst_ms_set; }
136 { p_name = -1; p_weight = 0.0; p_type =
ty; }
137 int name()
const {
return p_name; }
138 void set_name(
int i) { p_name = i; }
139 float weight()
const {
return p_weight; }
140 void set_weight(
float w) { p_weight = w; }
141 void set_type(
enum wfst_mstate_type s) { p_type = s; }
142 enum wfst_mstate_type type()
const {
return p_type; }
160 int operator_and(
LISP l);
161 int operator_or(
LISP l);
162 int operator_star(
LISP l);
163 int operator_plus(
LISP l);
164 int operator_optional(
LISP l);
165 int operator_not(
LISP l);
166 int terminal(
LISP l);
170 void extend_alphabets(
const EST_WFST &b);
172 EST_read_status load_transitions_from_lisp(
int s,
LISP trans);
175 int can_reach_final(
int state);
176 static int traverse_tag;
201 int num_states()
const {
return p_num_states; }
202 int start_state()
const {
return p_start_state; }
205 {
return p_in_symbols.
name(s); }
208 {
return p_in_symbols.
name(i); }
211 {
return p_out_symbols.
name(s); }
214 {
return p_out_symbols.
name(i); }
226 int final(
int i)
const
227 {
return ((i != WFST_ERROR_STATE) && (
state(i)->type() == wfst_final));}
240 EST_write_status save_binary(
FILE *fd);
244 EST_read_status load_binary(
FILE *fd,
356 int in,
int out)
const;
393int recognize_for_perplexity(
const EST_WFST &wfst,
398int recognize_for_perplexity(
const EST_WFST &wfst,
405VAL_REGISTER_CLASS_DCLS(wfst,
EST_WFST)
const EST_String & name(const int n) const
The name given the index.
void difference(const EST_WFST &a, const EST_WFST &b)
void start_cumulate()
Clear and start cumulation.
int add_state(enum wfst_state_type state_type)
Add a new state, returns new name.
const EST_String & out_symbol(int i) const
Map output alphabet index to output symbol.
EST_WFST_State * state_non_const(int i)
Return internal state information (non-const)
EST_WFST & operator=(const EST_WFST &a)
?
const EST_String & in_symbol(int i) const
Map input alphabet index to input symbol.
void uunion(EST_TList< EST_WFST > &wl)
void add_epsilon_reachable(EST_WFST_MultiState *ms) const
Extend multi-state with epsilon reachable states.
void complement(const EST_WFST &a)
Build complement of a.
EST_WFST_Transition * find_transition(int state, int in, int out) const
Find (first) transition given in and out symbols.
void init(int init_num_states=10)
Clear with (estimation of number of states required)
void clear()
clear removing existing states if any
void transition_all(int state, int in, int out, EST_WFST_MultiState *ms) const
Find all possible transitions for given state/input/output.
void compose(const EST_WFST &a, const EST_WFST &b)
EST_WFST_MultiState * apply_multistate(const EST_WFST &wfst, EST_WFST_MultiState *ms, int in, int out) const
Transduce a multi-state given n and out.
int out_epsilon() const
Internal index for output epsilon.
int in_symbol(const EST_String &s) const
Map input symbol to input alphabet index.
void remove_error_states(const EST_WFST &a)
Remove error states from the WFST.
EST_WFST(const EST_WFST &wfst)
?
void build_wfst(int start, int end, LISP regex)
Basic regex constructor.
int in_epsilon() const
Internal index for input epsilon.
int deterministic() const
True if WFST is deterministic.
void copy(const EST_WFST &wfst)
Copy from existing wfst.
EST_write_status save(const EST_String &filename, const EST_String type="ascii")
?
int cumulate() const
Cumulation condition.
const EST_WFST_State * state(int i) const
Return internal state information.
int out_symbol(const EST_String &s) const
Map output symbol to output alphabet index.
LISP epsilon_label() const
LISP for on epsilon symbols.
const EST_Discrete & out_symbols() const
Accessing the output alphabet.
void stop_cumulate()
Stop cumulation and calculate probabilities on transitions.
void build_or_transition(int start, int end, LISP disjunctions)
Basic disjunction constructor.
void minimize(const EST_WFST &a)
Build minimized form of a.
int transduce(int state, int in, int &out) const
Transduce in to out from state.
enum wfst_state_type ms_type(EST_WFST_MultiState *ms) const
Given a multi-state return type (final, ok, error)
void concat(const EST_WFST &a, const EST_WFST &b)
void intersection(EST_TList< EST_WFST > &wl)
void determinize(const EST_WFST &a)
Build determinized form of a.
EST_read_status load(const EST_String &filename)
?
int transition(int state, int in, int out) const
Find (first) new state given in and out symbols.
void build_and_transition(int start, int end, LISP conjunctions)
Basic conjunction constructor.
const EST_Discrete & in_symbols() const
Accessing the input alphabet.