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 {
00039 return m_begins[scoreBookkeepingID];
00040 }
00042 size_t GetEndIndex(size_t scoreBookkeepingID) const {
00043 return m_ends[scoreBookkeepingID];
00044 }
00046 size_t GetTotalNumberOfScores() const {
00047 return m_last;
00048 }
00050 void PrintLabeledScores(std::ostream& os, const ScoreComponentCollection& scc) const;
00052 void PrintLabeledWeightedScores(std::ostream& os, const ScoreComponentCollection& scc, const std::vector<float>& weights) const;
00053 #ifdef HAVE_PROTOBUF
00054 void SerializeFeatureNamesToPB(hgmert::Hypergraph* hg) const;
00055 #endif
00056 void InitWeightVectorFromFile(const std::string& fnam, std::vector<float>* m_allWeights) const;
00057 private:
00058 ScoreIndexManager(const ScoreIndexManager&);
00059
00060 std::vector<size_t> m_begins;
00061 std::vector<size_t> m_ends;
00062 std::vector<const ScoreProducer*> m_producers;
00063 std::vector<std::string> m_featureNames;
00064 std::vector<std::string> m_featureShortNames;
00065 size_t m_last;
00066 };
00067
00068
00069 }
00070
00071 #endif