aboutsummaryrefslogtreecommitdiff
path: root/src/include/fst/visit.h
diff options
context:
space:
mode:
authorAlexander Gutkin <agutkin@google.com>2013-02-28 00:24:20 +0000
committerAlexander Gutkin <agutkin@google.com>2013-02-28 00:24:20 +0000
commit5b6dc79427b8f7eeb6a7ff68034ab8548ce670ea (patch)
tree19e17fc79b8873e66f211276d4dd169c480cede1 /src/include/fst/visit.h
parent3da1eb108d36da35333b2d655202791af854996b (diff)
downloadopenfst-5b6dc79427b8f7eeb6a7ff68034ab8548ce670ea.tar.gz
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
Diffstat (limited to 'src/include/fst/visit.h')
-rw-r--r--src/include/fst/visit.h21
1 files changed, 17 insertions, 4 deletions
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 A>
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<A> &ifst) { nvisit_ = 0; }
+ void InitVisit(const Fst<A> &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_;
+
};