From fe91371a77ec43cc08d284ac49f00af8baa1a298 Mon Sep 17 00:00:00 2001 From: graehl Date: Sun, 25 Jul 2010 19:32:34 +0000 Subject: fixed CreateViterbiHypergraph (old impl did not work), so --show_derivation works git-svn-id: https://ws10smt.googlecode.com/svn/trunk@408 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/indices_after.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'decoder/indices_after.h') diff --git a/decoder/indices_after.h b/decoder/indices_after.h index ad94c576..dec94cc0 100755 --- a/decoder/indices_after.h +++ b/decoder/indices_after.h @@ -3,6 +3,7 @@ #include // STATIC_CONSTANT #include //swap +#include // iterator wrapper. inverts boolean value. template @@ -47,7 +48,8 @@ unsigned new_indices(KEEP keep,O out) { return new_indices(keep.begin(),keep.end(),out); } -// given a vector and a parallel sequence of bools where true means keep, keep only the marked elements while maintaining order +// given a vector and a parallel sequence of bools where true means keep, keep only the marked elements while maintaining order. +// this is done with a parallel sequence to the input, marked with positions the kept items would map into in a destination array, with removed items marked with the index -1. the reverse would be more compact (parallel to destination array, index of input item that goes into it) but would require the input sequence be random access. struct indices_after { BOOST_STATIC_CONSTANT(unsigned,REMOVED=(unsigned)-1); @@ -142,6 +144,21 @@ struct indices_after to[map[i]]=v[i]; } + //transform collection of indices into what we're remapping. (input/output iterators) + template + void reindex(IndexI i,IndexI const end,IndexO o) const { + for(;i + void reindex_push_back(VecI const& i,VecO &o) const { + reindex(i.begin(),i.end(),std::back_inserter(o)); + } + private: indices_after(indices_after const& o) { -- cgit v1.2.3