bool Done() const { return pos_ >= num_arcs_; } More...
#include <fst/compact-fst.h>
Public Types | |
| typedef A | Arc |
| typedef A::Label | Element |
| typedef A::Label | Label |
| typedef A::StateId | StateId |
| typedef A::Weight | Weight |
Public Member Functions | |
| Element | Compact (StateId s, const A &arc) const |
| Arc | Expand (StateId s, const Element &p, uint32 f=kArcValueFlags) const |
| ssize_t | Size () const |
| uint64 | Properties () const |
| bool | Compatible (const Fst< A > &fst) const |
| bool | Write (ostream &strm) const |
Static Public Member Functions | |
| static const string & | Type () |
| static StringCompactor * | Read (istream &strm) |
bool Done() const { return pos_ >= num_arcs_; }
// Specialization for CompactFst. This is an optionally caching arc iterator. TODO(allauzen): implements the kArcValueFlags, the current implementation only implements the kArcNoCache flag. template <class A, class C, class U> class ArcIterator< CompactFst<A, C, U> > { public: typedef typename A::StateId StateId; ArcIterator(const CompactFst<A, C, U> &fst, StateId s) : fst_(fst), state_(s), pos_(0), num_arcs_(0), offset_(0), flags_(kArcValueFlags) { cache_data_.ref_count = 0; if (fst_.GetImpl()->HasArcs(state_)) { fst_.GetImpl()->InitArcIterator(s, &cache_data_); num_arcs_ = cache_data_.narcs; return; } const C *compactor = fst_.GetImpl()->GetCompactor(); const CompactFstData<A, C, U> *data = fst_.GetImpl()->Data(); if (compactor->Size() == -1) { // Variable out-degree compactor offset_ = data->States(s); num_arcs_ = data->States(s + 1) - offset_; } else { // Fixed out-degree compactor offset_ = s * compactor->Size(); num_arcs_ = compactor->Size(); } if (num_arcs_ > 0) { const A &arc = fst_.GetImpl()->ComputeArc(s, offset_); if (arc.ilabel == kNoStateId) { ++offset_; --num_arcs_; } } } ~ArcIterator() { if (cache_data_.ref_count) --(*cache_data_.ref_count); } const A& Value() const { if (cache_data_.ref_count == 0) { if (flags_ & kArcNoCache) { arc_ = fst_.GetImpl()->ComputeArc(state_, pos_ + offset_); return arc_; } else { fst_.GetImpl()->InitArcIterator(state_, &cache_data_); } } return cache_data_.arcs[pos_]; } void Next() { ++pos_; } size_t Position() const { return pos_; } void Reset() { pos_ = 0; } void Seek(size_t pos) { pos_ = pos; } uint32 Flags() const { return flags_; } void SetFlags(uint32 f, uint32 m) { flags_ &= ~m; flags_ |= f; if (!(flags_ & kArcNoCache) && cache_data_.ref_count == 0) fst_.GetImpl()->InitArcIterator(state_, &cache_data_); } private: mutable const CompactFst<A, C, U> StateId state_; size_t pos_; size_t num_arcs_; size_t offset_; uint32 flags_; mutable A arc_; mutable ArcIteratorData cache_data_; DISALLOW_COPY_AND_ASSIGN(ArcIterator); }; Utility Compactors Compactor for unweighted string FSTs
Definition at line 1000 of file compact-fst.h.
| typedef A fst::StringCompactor< A >::Arc |
Definition at line 1002 of file compact-fst.h.
| typedef A::Label fst::StringCompactor< A >::Element |
Definition at line 1003 of file compact-fst.h.
| typedef A::Label fst::StringCompactor< A >::Label |
Definition at line 1004 of file compact-fst.h.
| typedef A::StateId fst::StringCompactor< A >::StateId |
Definition at line 1005 of file compact-fst.h.
| typedef A::Weight fst::StringCompactor< A >::Weight |
Definition at line 1006 of file compact-fst.h.
| Element fst::StringCompactor< A >::Compact | ( | StateId | s, | |
| const A & | arc | |||
| ) | const [inline] |
Definition at line 1008 of file compact-fst.h.
| bool fst::StringCompactor< A >::Compatible | ( | const Fst< A > & | fst | ) | const [inline] |
Definition at line 1020 of file compact-fst.h.
| Arc fst::StringCompactor< A >::Expand | ( | StateId | s, | |
| const Element & | p, | |||
| uint32 | f = kArcValueFlags | |||
| ) | const [inline] |
Definition at line 1010 of file compact-fst.h.
| uint64 fst::StringCompactor< A >::Properties | ( | ) | const [inline] |
Definition at line 1016 of file compact-fst.h.
| static StringCompactor* fst::StringCompactor< A >::Read | ( | istream & | strm | ) | [inline, static] |
Definition at line 1032 of file compact-fst.h.
| ssize_t fst::StringCompactor< A >::Size | ( | ) | const [inline] |
Definition at line 1014 of file compact-fst.h.
| static const string& fst::StringCompactor< A >::Type | ( | void | ) | [inline, static] |
Definition at line 1025 of file compact-fst.h.
| bool fst::StringCompactor< A >::Write | ( | ostream & | strm | ) | const [inline] |
Definition at line 1030 of file compact-fst.h.
1.7.1