All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Fst_extensions

Classes

struct  DeterminizeLatticeOptions
 
struct  DeterminizeLatticePrunedOptions
 
struct  DeterminizeLatticePhonePrunedOptions
 

Functions

template<class Weight , class IntType >
bool DeterminizeLattice (const Fst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< Weight > > *ofst, DeterminizeLatticeOptions opts=DeterminizeLatticeOptions(), bool *debug_ptr=NULL)
 This function implements the normal version of DeterminizeLattice, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side. More...
 
template<class Weight , class IntType >
bool DeterminizeLattice (const Fst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticeOptions opts, bool *debug_ptr)
 
template<class F >
bool DeterminizeStar (F &ifst, MutableFst< typename F::Arc > *ofst, float delta=kDelta, bool *debug_ptr=NULL, int max_states=-1, bool allow_partial=false)
 This function implements the normal version of DeterminizeStar, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side. More...
 
template<class F >
bool DeterminizeStar (F &ifst, MutableFst< GallicArc< typename F::Arc > > *ofst, float delta, bool *debug_ptr, int max_states, bool allow_partial)
 
template<class Weight >
bool DeterminizeLatticePruned (const ExpandedFst< ArcTpl< Weight > > &ifst, double prune, MutableFst< ArcTpl< Weight > > *ofst, DeterminizeLatticePrunedOptions opts=DeterminizeLatticePrunedOptions())
 This function implements the normal version of DeterminizeLattice, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side. More...
 
template<class Weight , class IntType >
bool DeterminizeLatticePruned (const ExpandedFst< ArcTpl< Weight > > &ifst, double beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePrunedOptions opts)
 
template<class Weight >
ArcTpl< Weight >::Label DeterminizeLatticeInsertPhones (const kaldi::TransitionModel &trans_model, MutableFst< ArcTpl< Weight > > *fst)
 This function takes in lattices and inserts phones at phone boundaries. More...
 
template<class Weight >
void DeterminizeLatticeDeletePhones (typename ArcTpl< Weight >::Label first_phone_label, MutableFst< ArcTpl< Weight > > *fst)
 This function takes in lattices and deletes "phones" from them. More...
 
template<class Weight , class IntType >
bool DeterminizeLatticePhonePruned (const kaldi::TransitionModel &trans_model, const ExpandedFst< ArcTpl< Weight > > &ifst, double prune, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePhonePrunedOptions opts=DeterminizeLatticePhonePrunedOptions())
 This function is a wrapper of DeterminizeLatticePhonePrunedFirstPass() and DeterminizeLatticePruned(). More...
 
template<class Weight , class IntType >
bool DeterminizeLatticePhonePruned (const kaldi::TransitionModel &trans_model, MutableFst< ArcTpl< Weight > > *ifst, double prune, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePhonePrunedOptions opts=DeterminizeLatticePhonePrunedOptions())
 "Destructive" version of DeterminizeLatticePhonePruned() where the input lattice might be changed. More...
 
bool DeterminizeLatticePhonePrunedWrapper (const kaldi::TransitionModel &trans_model, MutableFst< kaldi::LatticeArc > *ifst, double prune, MutableFst< kaldi::CompactLatticeArc > *ofst, DeterminizeLatticePhonePrunedOptions opts=DeterminizeLatticePhonePrunedOptions())
 This function is a wrapper of DeterminizeLatticePhonePruned() that works for Lattice type FSTs. More...
 

Detailed Description

Function Documentation

bool DeterminizeLattice ( const Fst< ArcTpl< Weight > > &  ifst,
MutableFst< ArcTpl< Weight > > *  ofst,
DeterminizeLatticeOptions  opts = DeterminizeLatticeOptions(),
bool *  debug_ptr = NULL 
)

This function implements the normal version of DeterminizeLattice, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side.

The debug_ptr argument is an optional pointer to a bool that, if it becomes true while the algorithm is executing, the algorithm will print a traceback and terminate (used in fstdeterminizestar.cc debug non-terminating determinization). More efficient if ifst is arc-sorted on input label. If the number of arcs gets more than max_states, it will throw std::runtime_error (otherwise this code does not use exceptions). This is mainly useful for debug.

Definition at line 1264 of file determinize-lattice-inl.h.

References LatticeDeterminizer< Weight, IntType >::Determinize(), and LatticeDeterminizer< Weight, IntType >::Output().

Referenced by kaldi::DeterminizeLatticeWrapper(), main(), and kaldi::RandDeterministicCompactLattice().

1267  {
1268  ofst->SetInputSymbols(ifst.InputSymbols());
1269  ofst->SetOutputSymbols(ifst.OutputSymbols());
1270  LatticeDeterminizer<Weight, IntType> det(ifst, opts);
1271  if (!det.Determinize(debug_ptr))
1272  return false;
1273  det.Output(ofst);
1274  return true;
1275 }
bool DeterminizeLattice ( const Fst< ArcTpl< Weight > > &  ifst,
MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *  ofst,
DeterminizeLatticeOptions  opts,
bool *  debug_ptr 
)

Definition at line 1281 of file determinize-lattice-inl.h.

References LatticeDeterminizer< Weight, IntType >::Determinize(), and LatticeDeterminizer< Weight, IntType >::Output().

1284  {
1285  ofst->SetInputSymbols(ifst.InputSymbols());
1286  ofst->SetOutputSymbols(ifst.OutputSymbols());
1287  LatticeDeterminizer<Weight, IntType> det(ifst, opts);
1288  if (!det.Determinize(debug_ptr))
1289  return false;
1290  det.Output(ofst);
1291  return true;
1292 }
void DeterminizeLatticeDeletePhones ( typename ArcTpl< Weight >::Label  first_phone_label,
MutableFst< ArcTpl< Weight > > *  fst 
)

This function takes in lattices and deletes "phones" from them.

The "phones" here are actually any label that is larger than first_phone_label because when we insert phones into the lattice, we map the original phone label to (first_phone_label + original_phone_label). It is supposed to be used together with DeterminizeLatticeInsertPhones()

Definition at line 1349 of file determinize-lattice-pruned.cc.

1351  {
1352  // Define some types.
1353  typedef ArcTpl<Weight> Arc;
1354  typedef typename Arc::StateId StateId;
1355  typedef typename Arc::Label Label;
1356 
1357  // Delete phones here.
1358  for (StateIterator<MutableFst<Arc> > siter(*fst);
1359  !siter.Done(); siter.Next()) {
1360  StateId state = siter.Value();
1361  for (MutableArcIterator<MutableFst<Arc> > aiter(fst, state);
1362  !aiter.Done(); aiter.Next()) {
1363  Arc arc = aiter.Value();
1364 
1365  if (arc.ilabel >= first_phone_label)
1366  arc.ilabel = 0;
1367 
1368  aiter.SetValue(arc);
1369  }
1370  }
1371 }
fst::StdArc::StateId StateId
Definition: graph.dox:21
fst::StdArc::Label Label
ArcTpl< Weight >::Label DeterminizeLatticeInsertPhones ( const kaldi::TransitionModel trans_model,
MutableFst< ArcTpl< Weight > > *  fst 
)

This function takes in lattices and inserts phones at phone boundaries.

It uses the transition model to work out the transition_id to phone map. The returning value is the starting index of the phone label. Typically we pick (maximum_output_label_index + 1) as this value. The inserted phones are then mapped to (returning_value + original_phone_label) in the new lattice. The returning value will be used by DeterminizeLatticeDeletePhones() where it works out the phones according to this value.

Definition at line 1293 of file determinize-lattice-pruned.cc.

References fst::HighestNumberedInputSymbol(), TransitionModel::IsSelfLoop(), KALDI_ASSERT, TransitionModel::TransitionIdToHmmState(), and TransitionModel::TransitionIdToPhone().

Referenced by fst::DeterminizeLatticePhonePrunedFirstPass().

1295  {
1296  // Define some types.
1297  typedef ArcTpl<Weight> Arc;
1298  typedef typename Arc::StateId StateId;
1299  typedef typename Arc::Label Label;
1300 
1301  // Work out the first phone symbol. This is more related to the phone
1302  // insertion function, so we put it here and make it the returning value of
1303  // DeterminizeLatticeInsertPhones().
1304  Label first_phone_label = HighestNumberedInputSymbol(*fst) + 1;
1305 
1306  // Insert phones here.
1307  for (StateIterator<MutableFst<Arc> > siter(*fst);
1308  !siter.Done(); siter.Next()) {
1309  StateId state = siter.Value();
1310  if (state == fst->Start())
1311  continue;
1312  for (MutableArcIterator<MutableFst<Arc> > aiter(fst, state);
1313  !aiter.Done(); aiter.Next()) {
1314  Arc arc = aiter.Value();
1315 
1316  // Note: the words are on the input symbol side and transition-id's are on
1317  // the output symbol side.
1318  if ((arc.olabel != 0)
1319  && (trans_model.TransitionIdToHmmState(arc.olabel) == 0)
1320  && (!trans_model.IsSelfLoop(arc.olabel))) {
1321  Label phone =
1322  static_cast<Label>(trans_model.TransitionIdToPhone(arc.olabel));
1323 
1324  // Skips <eps>.
1325  KALDI_ASSERT(phone != 0);
1326 
1327  if (arc.ilabel == 0) {
1328  // If there is no word on the arc, insert the phone directly.
1329  arc.ilabel = first_phone_label + phone;
1330  } else {
1331  // Otherwise, add an additional arc.
1332  StateId additional_state = fst->AddState();
1333  StateId next_state = arc.nextstate;
1334  arc.nextstate = additional_state;
1335  fst->AddArc(additional_state,
1336  Arc(first_phone_label + phone, 0,
1337  Weight::One(), next_state));
1338  }
1339  }
1340 
1341  aiter.SetValue(arc);
1342  }
1343  }
1344 
1345  return first_phone_label;
1346 }
fst::StdArc::StateId StateId
Definition: graph.dox:21
int32 TransitionIdToHmmState(int32 trans_id) const
fst::StdArc::Label Label
bool IsSelfLoop(int32 trans_id) const
Arc::Label HighestNumberedInputSymbol(const Fst< Arc > &fst)
Returns the highest numbered input symbol id of the FST (or zero for an empty FST.
int32 TransitionIdToPhone(int32 trans_id) const
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
bool DeterminizeLatticePhonePruned ( const kaldi::TransitionModel trans_model,
MutableFst< ArcTpl< Weight > > *  ifst,
double  beam,
MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *  ofst,
DeterminizeLatticePhonePrunedOptions  opts 
)

"Destructive" version of DeterminizeLatticePhonePruned() where the input lattice might be changed.

Definition at line 1413 of file determinize-lattice-pruned.cc.

References DeterminizeLatticePrunedOptions::delta, DeterminizeLatticePhonePrunedOptions::delta, KALDI_VLOG, KALDI_WARN, DeterminizeLatticePrunedOptions::max_mem, DeterminizeLatticePhonePrunedOptions::max_mem, DeterminizeLatticePhonePrunedOptions::minimize, DeterminizeLatticePhonePrunedOptions::phone_determinize, and DeterminizeLatticePhonePrunedOptions::word_determinize.

1418  {
1419  // Returning status.
1420  bool ans = true;
1421 
1422  // Make sure at least one of opts.phone_determinize and opts.word_determinize
1423  // is not false, otherwise calling this function doesn't make any sense.
1424  if ((opts.phone_determinize || opts.word_determinize) == false) {
1425  KALDI_WARN << "Both --phone-determinize and --word-determinize are set to "
1426  << "false, copying lattice without determinization.";
1427  // We are expecting the words on the input side.
1428  ConvertLattice<Weight, IntType>(*ifst, ofst, false);
1429  return ans;
1430  }
1431 
1432  // Determinization options.
1433  DeterminizeLatticePrunedOptions det_opts;
1434  det_opts.delta = opts.delta;
1435  det_opts.max_mem = opts.max_mem;
1436 
1437  // If --phone-determinize is true, do the determinization on phone + word
1438  // lattices.
1439  if (opts.phone_determinize) {
1440  KALDI_VLOG(1) << "Doing first pass of determinization on phone + word "
1441  << "lattices.";
1442  ans = DeterminizeLatticePhonePrunedFirstPass<Weight, IntType>(
1443  trans_model, beam, ifst, det_opts) && ans;
1444 
1445  // If --word-determinize is false, we've finished the job and return here.
1446  if (!opts.word_determinize) {
1447  // We are expecting the words on the input side.
1448  ConvertLattice<Weight, IntType>(*ifst, ofst, false);
1449  return ans;
1450  }
1451  }
1452 
1453  // If --word-determinize is true, do the determinization on word lattices.
1454  if (opts.word_determinize) {
1455  KALDI_VLOG(1) << "Doing second pass of determinization on word lattices.";
1456  ans = DeterminizeLatticePruned<Weight, IntType>(
1457  *ifst, beam, ofst, det_opts) && ans;
1458  }
1459 
1460  // If --minimize is true, push and minimize after determinization.
1461  if (opts.minimize) {
1462  KALDI_VLOG(1) << "Pushing and minimizing on word lattices.";
1463  ans = PushCompactLatticeStrings<Weight, IntType>(ofst) && ans;
1464  ans = PushCompactLatticeWeights<Weight, IntType>(ofst) && ans;
1465  ans = MinimizeCompactLattice<Weight, IntType>(ofst) && ans;
1466  }
1467 
1468  return ans;
1469 }
#define KALDI_WARN
Definition: kaldi-error.h:130
#define KALDI_VLOG(v)
Definition: kaldi-error.h:136
bool DeterminizeLatticePhonePruned ( const kaldi::TransitionModel trans_model,
const ExpandedFst< ArcTpl< Weight > > &  ifst,
double  prune,
MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *  ofst,
DeterminizeLatticePhonePrunedOptions  opts = DeterminizeLatticePhonePrunedOptions() 
)

This function is a wrapper of DeterminizeLatticePhonePrunedFirstPass() and DeterminizeLatticePruned().

If –phone-determinize is set to true, it first calls DeterminizeLatticePhonePrunedFirstPass() to do the initial pass of determinization on the phone + word lattices. If –word-determinize is set true, it then does a second pass of determinization on the word lattices by calling DeterminizeLatticePruned(). If both are set to false, then it gives a warning and copying the lattices without determinization.

Note: the point of doing first a phone-level determinization pass and then a word-level determinization pass is that it allows us to determinize deeper lattices without "failing early" and returning a too-small lattice due to the max-mem constraint. The result should be the same as word-level determinization in general, but for deeper lattices it is a bit faster, despite the fact that we now have two passes of determinization by default.

Definition at line 1474 of file determinize-lattice-pruned.cc.

1479  {
1480  VectorFst<ArcTpl<Weight> > temp_fst(ifst);
1481  return DeterminizeLatticePhonePruned(trans_model, &temp_fst,
1482  beam, ofst, opts);
1483 }
bool DeterminizeLatticePhonePruned(const kaldi::TransitionModel &trans_model, const ExpandedFst< ArcTpl< Weight > > &ifst, double beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePhonePrunedOptions opts)
This function is a wrapper of DeterminizeLatticePhonePrunedFirstPass() and DeterminizeLatticePruned()...
bool DeterminizeLatticePhonePrunedWrapper ( const kaldi::TransitionModel trans_model,
MutableFst< kaldi::LatticeArc > *  ifst,
double  prune,
MutableFst< kaldi::CompactLatticeArc > *  ofst,
DeterminizeLatticePhonePrunedOptions  opts = DeterminizeLatticePhonePrunedOptions() 
)

This function is a wrapper of DeterminizeLatticePhonePruned() that works for Lattice type FSTs.

It simplifies the calling process by calling TopSort() Invert() and ArcSort() for you. Unlike other determinization routines, the function requires "ifst" to have transition-id's on the input side and words on the output side. This function can be used as the top-level interface to all the determinization code.

Definition at line 1485 of file determinize-lattice-pruned.cc.

References KALDI_ERR.

Referenced by kaldi::DecodeUtterance(), kaldi::DecodeUtteranceLatticeFaster(), kaldi::DecodeUtteranceLatticeSimple(), main(), DeterminizeLatticeTask::operator()(), and DecodeUtteranceLatticeFasterClass::operator()().

1490  {
1491  bool ans = true;
1492  Invert(ifst);
1493  if (ifst->Properties(fst::kTopSorted, true) == 0) {
1494  if (!TopSort(ifst)) {
1495  // Cannot topologically sort the lattice -- determinization will fail.
1496  KALDI_ERR << "Topological sorting of state-level lattice failed (probably"
1497  << " your lexicon has empty words or your LM has epsilon cycles"
1498  << ").";
1499  }
1500  }
1501  ILabelCompare<kaldi::LatticeArc> ilabel_comp;
1502  ArcSort(ifst, ilabel_comp);
1503  ans = DeterminizeLatticePhonePruned<kaldi::LatticeWeight, kaldi::int32>(
1504  trans_model, ifst, beam, ofst, opts);
1505  Connect(ofst);
1506  return ans;
1507 }
#define KALDI_ERR
Definition: kaldi-error.h:127
bool DeterminizeLatticePruned ( const ExpandedFst< ArcTpl< Weight > > &  ifst,
double  beam,
MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *  ofst,
DeterminizeLatticePrunedOptions  opts 
)

Definition at line 1193 of file determinize-lattice-pruned.cc.

References LatticeDeterminizerPruned< Weight, IntType >::Determinize(), KALDI_ASSERT, KALDI_LOG, LatticeDeterminizerPruned< Weight, IntType >::Output(), kaldi::PruneLattice(), and DeterminizeLatticePrunedOptions::retry_cutoff.

Referenced by LatticeSimpleDecoder::GetLattice(), LatticeFasterDecoder::GetLattice(), LatticeBiglmFasterDecoder::GetLattice(), main(), DeterminizeLatticeTask::operator()(), and kaldi::SentenceLevelConfidence().

1197  {
1198  ofst->SetInputSymbols(ifst.InputSymbols());
1199  ofst->SetOutputSymbols(ifst.OutputSymbols());
1200  if (ifst.NumStates() == 0) {
1201  ofst->DeleteStates();
1202  return true;
1203  }
1204  KALDI_ASSERT(opts.retry_cutoff >= 0.0 && opts.retry_cutoff < 1.0);
1205  int32 max_num_iters = 10; // avoid the potential for infinite loops if
1206  // retrying.
1207  VectorFst<ArcTpl<Weight> > temp_fst;
1208 
1209  for (int32 iter = 0; iter < max_num_iters; iter++) {
1210  LatticeDeterminizerPruned<Weight, IntType> det(iter == 0 ? ifst : temp_fst,
1211  beam, opts);
1212  double effective_beam;
1213  bool ans = det.Determinize(&effective_beam);
1214  // if it returns false it will typically still produce reasonable output,
1215  // just with a narrower beam than "beam". If the user specifies an infinite
1216  // beam we don't do this beam-narrowing.
1217  if (effective_beam >= beam * opts.retry_cutoff ||
1218  beam == std::numeric_limits<double>::infinity() ||
1219  iter + 1 == max_num_iters) {
1220  det.Output(ofst);
1221  return ans;
1222  } else {
1223  // The code below to set "beam" is a heuristic.
1224  // If effective_beam is very small, we want to reduce by a lot.
1225  // But never change the beam by more than a factor of two.
1226  if (effective_beam < 0.0) effective_beam = 0.0;
1227  double new_beam = beam * sqrt(effective_beam / beam);
1228  if (new_beam < 0.5 * beam) new_beam = 0.5 * beam;
1229  beam = new_beam;
1230  if (iter == 0) temp_fst = ifst;
1231  kaldi::PruneLattice(beam, &temp_fst);
1232  KALDI_LOG << "Pruned state-level lattice with beam " << beam
1233  << " and retrying determinization with that beam.";
1234  }
1235  }
1236  return false; // Suppress compiler warning; this code is unreachable.
1237 }
bool PruneLattice(BaseFloat beam, LatType *lat)
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
#define KALDI_LOG
Definition: kaldi-error.h:133
bool DeterminizeLatticePruned ( const ExpandedFst< ArcTpl< Weight > > &  ifst,
double  prune,
MutableFst< ArcTpl< Weight > > *  ofst,
DeterminizeLatticePrunedOptions  opts = DeterminizeLatticePrunedOptions() 
)

This function implements the normal version of DeterminizeLattice, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side.

It also prunes using the beam in the "prune" parameter. The input FST must be topologically sorted in order for the algorithm to work. For efficiency it is recommended to sort ilabel as well. Returns true on success, and false if it had to terminate the determinization earlier than specified by the "prune" beam– that is, if it terminated because of the max_mem, max_loop or max_arcs constraints in the options. CAUTION: you may want to use the version below which outputs to CompactLattice.

Definition at line 1245 of file determinize-lattice-pruned.cc.

References LatticeDeterminizerPruned< Weight, IntType >::Determinize(), KALDI_ASSERT, KALDI_WARN, LatticeDeterminizerPruned< Weight, IntType >::Output(), kaldi::PruneLattice(), and DeterminizeLatticePrunedOptions::retry_cutoff.

1248  {
1249  typedef int32 IntType;
1250  ofst->SetInputSymbols(ifst.InputSymbols());
1251  ofst->SetOutputSymbols(ifst.OutputSymbols());
1252  KALDI_ASSERT(opts.retry_cutoff >= 0.0 && opts.retry_cutoff < 1.0);
1253  if (ifst.NumStates() == 0) {
1254  ofst->DeleteStates();
1255  return true;
1256  }
1257  int32 max_num_iters = 10; // avoid the potential for infinite loops if
1258  // retrying.
1259  VectorFst<ArcTpl<Weight> > temp_fst;
1260 
1261  for (int32 iter = 0; iter < max_num_iters; iter++) {
1262  LatticeDeterminizerPruned<Weight, IntType> det(iter == 0 ? ifst : temp_fst,
1263  beam, opts);
1264  double effective_beam;
1265  bool ans = det.Determinize(&effective_beam);
1266  // if it returns false it will typically still
1267  // produce reasonable output, just with a
1268  // narrower beam than "beam".
1269  if (effective_beam >= beam * opts.retry_cutoff ||
1270  iter + 1 == max_num_iters) {
1271  det.Output(ofst);
1272  return ans;
1273  } else {
1274  // The code below to set "beam" is a heuristic.
1275  // If effective_beam is very small, we want to reduce by a lot.
1276  // But never change the beam by more than a factor of two.
1277  if (effective_beam < 0)
1278  effective_beam = 0;
1279  double new_beam = beam * sqrt(effective_beam / beam);
1280  if (new_beam < 0.5 * beam) new_beam = 0.5 * beam;
1281  KALDI_WARN << "Effective beam " << effective_beam << " was less than beam "
1282  << beam << " * cutoff " << opts.retry_cutoff << ", pruning raw "
1283  << "lattice with new beam " << new_beam << " and retrying.";
1284  beam = new_beam;
1285  if (iter == 0) temp_fst = ifst;
1286  kaldi::PruneLattice(beam, &temp_fst);
1287  }
1288  }
1289  return false; // Suppress compiler warning; this code is unreachable.
1290 }
#define KALDI_WARN
Definition: kaldi-error.h:130
bool PruneLattice(BaseFloat beam, LatType *lat)
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
bool DeterminizeStar ( F &  ifst,
MutableFst< typename F::Arc > *  ofst,
float  delta = kDelta,
bool *  debug_ptr = NULL,
int  max_states = -1,
bool  allow_partial = false 
)

This function implements the normal version of DeterminizeStar, in which the output strings are represented using sequences of arcs, where all but the first one has an epsilon on the input side.

The debug_ptr argument is an optional pointer to a bool that, if it becomes true while the algorithm is executing, the algorithm will print a traceback and terminate (used in fstdeterminizestar.cc debug non-terminating determinization). If max_states is positive, it will stop determinization and throw an exception as soon as the max-states is reached. This can be useful in test. If allow_partial is true, the algorithm will output partial results when the specified max_states is reached (when larger than zero), instead of throwing out an error. The function will return false if partial FST is generated, and true if the complete determinized FST is generated.

Definition at line 633 of file determinize-star-inl.h.

References DeterminizerStar< F >::Determinize(), DeterminizerStar< F >::IsPartial(), and DeterminizerStar< F >::Output().

Referenced by fst::DeterminizeStarInLog(), main(), fst::SafeDeterminizeMinimizeWrapper(), fst::SafeDeterminizeWrapper(), fst::TestDeterminize(), fst::TestFactor(), and fst::TestMinimize().

635  {
636  ofst->SetOutputSymbols(ifst.OutputSymbols());
637  ofst->SetInputSymbols(ifst.InputSymbols());
638  DeterminizerStar<F> det(ifst, delta, max_states, allow_partial);
639  det.Determinize(debug_ptr);
640  det.Output(ofst);
641  return det.IsPartial();
642 }
bool DeterminizeStar ( F &  ifst,
MutableFst< GallicArc< typename F::Arc > > *  ofst,
float  delta,
bool *  debug_ptr,
int  max_states,
bool  allow_partial 
)

Definition at line 646 of file determinize-star-inl.h.

References DeterminizerStar< F >::Determinize(), DeterminizerStar< F >::IsPartial(), and DeterminizerStar< F >::Output().

649  {
650  ofst->SetOutputSymbols(ifst.InputSymbols());
651  ofst->SetInputSymbols(ifst.InputSymbols());
652  DeterminizerStar<F> det(ifst, delta, max_states, allow_partial);
653  det.Determinize(debug_ptr);
654  det.Output(ofst);
655  return det.IsPartial();
656 }