00001 /* 00002 * StoreTarget.h 00003 * 00004 * Created on: 19 Jan 2016 00005 * Author: hieu 00006 */ 00007 #pragma once 00008 #include <string> 00009 #include <fstream> 00010 #include <vector> 00011 #include <inttypes.h> 00012 #include <boost/unordered_map.hpp> 00013 #include <boost/unordered_set.hpp> 00014 #include "StoreVocab.h" 00015 00016 namespace Moses 00017 { 00018 00019 class line_text; 00020 class target_text; 00021 00022 class StoreTarget 00023 { 00024 public: 00025 StoreTarget(const std::string &basepath); 00026 virtual ~StoreTarget(); 00027 00028 uint64_t Save(); 00029 void SaveAlignment(); 00030 00031 void Append(const line_text &line, bool log_prob, bool scfg); 00032 protected: 00033 std::string m_basePath; 00034 std::fstream m_fileTargetColl; 00035 StoreVocab<uint32_t> m_vocab; 00036 00037 typedef boost::unordered_map<std::vector<size_t>, uint32_t> Alignments; 00038 Alignments m_aligns; 00039 00040 std::vector<target_text*> m_coll; 00041 00042 uint32_t GetAlignId(const std::vector<size_t> &align); 00043 void Save(const target_text &rule); 00044 00045 void AppendLexRO(std::string &prop, std::vector<float> &retvector, 00046 bool log_prob) const; 00047 00048 }; 00049 00050 } /* namespace Moses2 */ 00051