mosesdecoder/contrib/other-builds/moses2/TargetPhrase.cpp

44 lines
1.0 KiB
C++
Raw Normal View History

2015-10-23 22:53:36 +03:00
/*
* TargetPhrase.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#include <stdlib.h>
#include "TargetPhrase.h"
#include "Scores.h"
#include "Manager.h"
2015-10-26 00:20:55 +03:00
#include "System.h"
2015-10-24 04:02:50 +03:00
#include "util/pool.hh"
2015-10-23 22:53:36 +03:00
2015-10-24 04:02:50 +03:00
using namespace std;
2015-10-26 00:20:55 +03:00
TargetPhrase *TargetPhrase::CreateFromString(util::Pool &pool, System &system, const std::string &str)
2015-10-23 22:53:36 +03:00
{
2015-10-26 17:58:59 +03:00
Moses::FactorCollection &vocab = system.GetVocab();
2015-10-24 04:02:50 +03:00
vector<string> toks = Moses::Tokenize(str);
size_t size = toks.size();
2015-10-26 00:20:55 +03:00
TargetPhrase *ret = new (pool.Allocate<TargetPhrase>()) TargetPhrase(pool, system, size);
2015-10-26 17:58:59 +03:00
ret->Phrase::CreateFromString(vocab, toks);
2015-10-23 22:53:36 +03:00
2015-10-24 04:02:50 +03:00
return ret;
}
2015-10-26 00:20:55 +03:00
TargetPhrase::TargetPhrase(util::Pool &pool, System &system, size_t size)
2015-10-24 04:14:52 +03:00
:Phrase(pool, size)
2015-10-24 04:02:50 +03:00
{
2015-10-27 20:00:38 +03:00
m_scores = new (pool.Allocate<Scores>()) Scores(pool, system.GetFeatureFunctions().GetNumScores());
2015-10-23 22:53:36 +03:00
}
TargetPhrase::~TargetPhrase() {
// TODO Auto-generated destructor stub
}
2015-10-26 19:32:47 +03:00
std::ostream& operator<<(std::ostream &out, const TargetPhrase &obj)
{
2015-10-26 21:42:42 +03:00
out << (const Phrase&) obj << " SCORES:" << obj.GetScores();
2015-10-26 19:32:47 +03:00
return out;
}