00001
00002
00003 #ifndef moses_ScoreIndexManager_h
00004 #define moses_ScoreIndexManager_h
00005
00006 #include <iostream>
00007 #include <vector>
00008 #if HAVE_CONFIG_H
00009 #include "config.h"
00010 #endif
00011 #ifdef HAVE_PROTOBUF
00012 #include "hypergraph.pb.h"
00013 #endif
00014
00015 namespace Moses
00016 {
00017
00018 class ScoreProducer;
00019 class ScoreComponentCollection;
00020 class StatefulFeatureFunction;
00021 class StatelessFeatureFunction;
00022
00027 class ScoreIndexManager
00028 {
00029 friend std::ostream& operator<<(std::ostream& os, const ScoreIndexManager& sim);
00030 public:
00031 ScoreIndexManager() : m_last(0) {}
00032
00034 void AddScoreProducer(const ScoreProducer* producer);
00035 void InitFeatureNames();
00036
00038 size_t GetBeginIndex(size_t scoreBookkeepingID) const { return m_begins[scoreBookkeepingID]; }
00040 size_t GetEndIndex(size_t scoreBookkeepingID) const { return m_ends[scoreBookkeepingID]; }
00042 size_t GetTotalNumberOfScores() const { return m_last; }
00044 void PrintLabeledScores(std::ostream& os, const ScoreComponentCollection& scc) const;
00046 void PrintLabeledWeightedScores(std::ostream& os, const ScoreComponentCollection& scc, const std::vector<float>& weights) const;
00047 #ifdef HAVE_PROTOBUF
00048 void SerializeFeatureNamesToPB(hgmert::Hypergraph* hg) const;
00049 #endif
00050 void InitWeightVectorFromFile(const std::string& fnam, std::vector<float>* m_allWeights) const;
00051 private:
00052 ScoreIndexManager(const ScoreIndexManager&);
00053
00054 std::vector<size_t> m_begins;
00055 std::vector<size_t> m_ends;
00056 std::vector<const ScoreProducer*> m_producers;
00057 std::vector<std::string> m_featureNames;
00058 std::vector<std::string> m_featureShortNames;
00059 size_t m_last;
00060 };
00061
00062
00063 }
00064
00065 #endif