this broke something, reverting..

Revert "fix LoadReferences() in StaticData and remove reference loading in mira's Main and Decoder"

This reverts commit 2ee9f47a5f.
This commit is contained in:
Eva Hasler 2011-10-20 13:43:30 +01:00
parent 51b54e0d9d
commit b263f14f63
4 changed files with 13 additions and 5 deletions

View File

@ -70,14 +70,14 @@ namespace Mira {
: m_manager(NULL) { : m_manager(NULL) {
// force initialisation of the phrase dictionary (TODO: why?) // force initialisation of the phrase dictionary (TODO: why?)
const StaticData &staticData = StaticData::Instance(); const StaticData &staticData = StaticData::Instance();
/*m_sentence = new Sentence(Input); m_sentence = new Sentence(Input);
stringstream in("Initialising decoder..\n"); stringstream in("Initialising decoder..\n");
const std::vector<FactorType> &inputFactorOrder = staticData.GetInputFactorOrder(); const std::vector<FactorType> &inputFactorOrder = staticData.GetInputFactorOrder();
m_sentence->Read(in,inputFactorOrder);*/ m_sentence->Read(in,inputFactorOrder);
const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT); const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT);
/*m_manager = new Manager(*m_sentence, staticData.GetSearchAlgorithm(), &system); m_manager = new Manager(*m_sentence, staticData.GetSearchAlgorithm(), &system);
m_manager->ProcessSentence();*/ m_manager->ProcessSentence();
// Add the bleu feature // Add the bleu feature
m_bleuScoreFeature = new BleuScoreFeature(scaleByInputLength, historySmoothing); m_bleuScoreFeature = new BleuScoreFeature(scaleByInputLength, historySmoothing);
@ -202,6 +202,10 @@ namespace Mira {
m_bleuScoreFeature->UpdateHistory(words, sourceLengths, ref_ids, rank, epoch); m_bleuScoreFeature->UpdateHistory(words, sourceLengths, ref_ids, rank, epoch);
} }
void MosesDecoder::loadReferenceSentences(const vector<vector<string> >& refs) {
m_bleuScoreFeature->LoadReferences(refs);
}
void MosesDecoder::printBleuFeatureHistory(std::ostream& out) { void MosesDecoder::printBleuFeatureHistory(std::ostream& out) {
m_bleuScoreFeature->PrintHistory(out); m_bleuScoreFeature->PrintHistory(out);
} }

View File

@ -67,6 +67,7 @@ class MosesDecoder {
size_t getCurrentInputLength(); size_t getCurrentInputLength();
void updateHistory(const std::vector<const Moses::Word*>& words); void updateHistory(const std::vector<const Moses::Word*>& words);
void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids, size_t rank, size_t epoch); void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids, size_t rank, size_t epoch);
void loadReferenceSentences(const std::vector<std::vector<std::string> >& refs);
void printBleuFeatureHistory(std::ostream& out); void printBleuFeatureHistory(std::ostream& out);
void printReferenceLength(const std::vector<size_t>& ref_ids); void printReferenceLength(const std::vector<size_t>& ref_ids);
Moses::ScoreComponentCollection getWeights(); Moses::ScoreComponentCollection getWeights();

View File

@ -321,6 +321,8 @@ int main(int argc, char** argv) {
} }
} }
decoder->loadReferenceSentences(referenceSentences);
#ifdef MPI_ENABLE #ifdef MPI_ENABLE
mpi::broadcast(world, order, 0); mpi::broadcast(world, order, 0);
#endif #endif

View File

@ -1298,7 +1298,7 @@ bool StaticData::LoadDecodeGraphs()
bool StaticData::LoadReferences() bool StaticData::LoadReferences()
{ {
vector<string> bleuWeightStr = m_parameter->GetParam("weight-bl"); vector<string> bleuWeightStr = m_parameter->GetParam("weight-b");
vector<string> referenceFiles = m_parameter->GetParam("references"); vector<string> referenceFiles = m_parameter->GetParam("references");
if ((!referenceFiles.size() && bleuWeightStr.size()) || (referenceFiles.size() && !bleuWeightStr.size())) { if ((!referenceFiles.size() && bleuWeightStr.size()) || (referenceFiles.size() && !bleuWeightStr.size())) {
UserMessage::Add("You cannot use the bleu feature without references, and vice-versa"); UserMessage::Add("You cannot use the bleu feature without references, and vice-versa");
@ -1338,6 +1338,7 @@ bool StaticData::LoadReferences()
} }
//Set the references in the bleu feature //Set the references in the bleu feature
m_bleuScoreFeature->LoadReferences(references); m_bleuScoreFeature->LoadReferences(references);
m_bleuScoreFeature->SetCurrentReference(0); //TODO: Temporary, for testing
return true; return true;
} }