diff options
author | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2015-02-20 23:53:25 +0300 |
---|---|---|
committer | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2015-02-20 23:53:25 +0300 |
commit | 9f4ebd83e0391fe585b6aef801323b7b20822dc1 (patch) | |
tree | bb6a776fd20b241db0595f7a371b0e7e218801a8 /moses | |
parent | fd08880bdec0ba508c60e5b0355283b1d4cd113e (diff) |
TargetPhrase: can store arbitrary data
Diffstat (limited to 'moses')
-rw-r--r-- | moses/TargetPhrase.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/moses/TargetPhrase.h b/moses/TargetPhrase.h index db7da97c5..04211e66b 100644 --- a/moses/TargetPhrase.h +++ b/moses/TargetPhrase.h @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "util/string_piece.hh" #include <boost/shared_ptr.hpp> +#include <boost/unordered_map.hpp> #ifdef HAVE_PROTOBUF #include "rule.pb.h" @@ -65,6 +66,8 @@ private: const PhraseDictionary *m_container; + mutable boost::unordered_map<const std::string, boost::shared_ptr<void> > m_data; + public: TargetPhrase(const PhraseDictionary *pt = NULL); TargetPhrase(std::string out_string, const PhraseDictionary *pt = NULL); @@ -166,6 +169,23 @@ public: return m_container; } + bool SetData(const std::string& key, boost::shared_ptr<void> value) const { + std::pair< boost::unordered_map<const std::string, boost::shared_ptr<void> >::iterator, bool > inserted = + m_data.insert( std::pair<const std::string, boost::shared_ptr<void> >(key,value) ); + if (!inserted.second) { + return false; + } + return true; + } + + boost::shared_ptr<void> GetData(const std::string& key) const { + boost::unordered_map<const std::string, boost::shared_ptr<void> >::const_iterator found = m_data.find(key); + if (found == m_data.end()) { + return boost::shared_ptr<void>(); + } + return found->second; + } + // To be set by the FF that needs it, by default the rule source = NULL // make a copy of the source side of the rule void SetRuleSource(const Phrase &ruleSource) const; |