From 5b6dc79427b8f7eeb6a7ff68034ab8548ce670ea Mon Sep 17 00:00:00 2001 From: Alexander Gutkin Date: Thu, 28 Feb 2013 00:24:20 +0000 Subject: Bumped OpenFST implementation to openfst-1.3.3-CL41851770. Updated OpenFST implementation to the most recent version used by Greco3 (corresponds to nlp::fst exported at Perforce CL 41851770). In particular this version has an improved PDT support. Change-Id: I5aadfc962297eef73922c67e7d57866f11ee7d81 --- src/include/fst/visit.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/include/fst/visit.h') diff --git a/src/include/fst/visit.h b/src/include/fst/visit.h index a02d86a..5f5059a 100644 --- a/src/include/fst/visit.h +++ b/src/include/fst/visit.h @@ -238,18 +238,28 @@ class CopyVisitor { }; -// Visits input FST up to a state limit following queue order. +// Visits input FST up to a state limit following queue order. If +// 'access_only' is true, aborts on visiting first state not +// accessible from the initial state. template class PartialVisitor { public: typedef A Arc; typedef typename A::StateId StateId; - explicit PartialVisitor(StateId maxvisit) : maxvisit_(maxvisit) {} + explicit PartialVisitor(StateId maxvisit, bool access_only = false) + : maxvisit_(maxvisit), + access_only_(access_only), + start_(kNoStateId) {} - void InitVisit(const Fst &ifst) { nvisit_ = 0; } + void InitVisit(const Fst &ifst) { + nvisit_ = 0; + start_ = ifst.Start(); + } - bool InitState(StateId s, StateId) { + bool InitState(StateId s, StateId root) { + if (access_only_ && root != start_) + return false; ++nvisit_; return nvisit_ <= maxvisit_; } @@ -262,7 +272,10 @@ class PartialVisitor { private: StateId maxvisit_; + bool access_only_; StateId nvisit_; + StateId start_; + }; -- cgit v1.2.3