Lines Matching defs:compactor

59 // * Fixed out-degree compactors: 'compactor.Size()' returns a
60 // positive integer 's'. An FST can be compacted by this compactor
63 // compactor for string FSTs, i.e. 's == 1'.
65 // * Variable out-degree compactors: 'compactor.Size() == -1'. There
82 // // Test whether 'fst' can be compacted by this compactor.
85 // // compacted using this compactor
87 // // Return a string identifying the type of compactor.
89 // // Write a compactor to a file.
91 // // Read a compactor from a file.
99 // with this new compactor). However, a default constructor always
116 // consecutively. For a given state 's', its 'compactor.Size()' outgoing
118 // stored in position ['s*compactor.Size()', '(s+1)*compactor_.Size()').
149 CompactFstData(const Fst<A> &fst, const Compactor &compactor);
153 const Compactor &compactor);
170 const Compactor &compactor);
202 CompactFstData<E, U>::CompactFstData(const Fst<A> &fst, const C &compactor)
228 if (compactor.Size() == -1) {
235 ncompacts_ = nstates_ * compactor.Size();
237 FSTERROR() << "CompactFstData: compactor incompatible with fst";
246 if (compactor.Size() == -1)
249 compacts_[pos++] = compactor.Compact(s, A(kNoLabel, kNoLabel,
254 compacts_[pos++] = compactor.Compact(s, aiter.Value());
256 if ((compactor.Size() != -1) && ((pos - fpos) != compactor.Size())) {
257 FSTERROR() << "CompactFstData: compactor incompatible with fst";
263 FSTERROR() << "CompactFstData: compactor incompatible with fst";
273 const C &compactor)
285 if (compactor.Size() != -1) {
287 if (compactor.Size() == 1) {
293 Arc arc = compactor.Expand(ncompacts_ - 1,
299 if (ncompacts_ % compactor.Size()) {
301 << " with compactor";
308 nstates_ = ncompacts_ / compactor.Size();
314 if (compactor.Expand(i, *it).ilabel != kNoLabel)
318 compacts_[i] = compactor.Compact(i, Arc(kNoLabel, kNoLabel,
326 Arc arc = compactor.Expand(i, *it);
342 Arc arc = compactor.Expand(i, *it);
365 const C &compactor) {
371 if (compactor.Size() == -1) {
389 data->ncompacts_ = compactor.Size() == -1
391 : data->nstates_ * compactor.Size();
482 CompactFstImpl(const Fst<Arc> &fst, const C &compactor,
485 compactor_(new C(compactor)),
491 CompactFstImpl(const Fst<Arc> &fst, C *compactor,
494 compactor_(compactor),
501 CompactFstImpl(const Iterator &b, const Iterator &e, const C &compactor,
504 compactor_(new C(compactor)),
511 CompactFstImpl(const Iterator &b, const Iterator &e, C *compactor,
514 compactor_(compactor),
743 FSTERROR() << "CompactFstImpl: input fst incompatible with compactor";
809 explicit CompactFst(const Fst<A> &fst, const C &compactor = C(),
811 : ImplToExpandedFst<Impl>(new Impl(fst, compactor, opts)) {}
813 CompactFst(const Fst<A> &fst, C *compactor,
815 : ImplToExpandedFst<Impl>(new Impl(fst, compactor, opts)) {}
824 // states. All strings (compactor of size 1) will be assume to be
838 const C &compactor = C(),
840 : ImplToExpandedFst<Impl>(new Impl(begin, end, compactor, opts)) {}
844 C *compactor, const CompactFstOptions &opts = CompactFstOptions())
845 : ImplToExpandedFst<Impl>(new Impl(begin, end, compactor, opts)) {}
878 static bool WriteFst(const F &fst, const C &compactor, ostream &strm,
928 const C &compactor,
938 C first_pass_compactor = compactor;
945 // A first pass is needed to compute the state of the compactor, which
977 if ((copy_properties & kError) || !compactor.Compatible(fst)) {
978 LOG(ERROR) << "fst incompatible with compactor";
1005 C second_pass_compactor = compactor;
1068 if (compactor_->Size() == -1) { // Variable out-degree compactor
1071 } else { // Fixed out-degree compactor
1141 // const C *compactor = fst_.GetImpl()->GetCompactor();
1143 // if (compactor->Size() == -1) { // Variable out-degree compactor
1146 // } else { // Fixed out-degree compactor
1147 // offset_ = s * compactor->Size();
1148 // num_arcs_ = compactor->Size();