2013-09-25 01:50:43 +04:00
|
|
|
// vim:tabstop=2
|
|
|
|
#include "SkeletonPT.h"
|
2013-09-25 23:59:13 +04:00
|
|
|
#include "moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h"
|
2013-09-25 01:50:43 +04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
SkeletonPT::SkeletonPT(const std::string &line)
|
2013-10-29 22:20:55 +04:00
|
|
|
: PhraseDictionary(line)
|
2013-09-25 01:50:43 +04:00
|
|
|
{
|
|
|
|
ReadParameters();
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:57:01 +04:00
|
|
|
void SkeletonPT::CleanUpAfterSentenceProcessing(const InputType& source)
|
|
|
|
{
|
2013-09-27 12:35:24 +04:00
|
|
|
RemoveAllInColl(m_allTPColl);
|
2013-09-25 19:57:01 +04:00
|
|
|
}
|
|
|
|
|
2013-10-03 21:58:45 +04:00
|
|
|
void SkeletonPT::GetTargetPhraseCollectionBatch(const InputPathList &inputPathQueue) const
|
2013-09-25 01:50:43 +04:00
|
|
|
{
|
|
|
|
InputPathList::const_iterator iter;
|
2013-10-03 21:58:45 +04:00
|
|
|
for (iter = inputPathQueue.begin(); iter != inputPathQueue.end(); ++iter) {
|
2013-09-25 01:50:43 +04:00
|
|
|
InputPath &inputPath = **iter;
|
2013-09-25 19:57:01 +04:00
|
|
|
|
|
|
|
TargetPhrase *tp = CreateTargetPhrase(inputPath.GetPhrase());
|
|
|
|
TargetPhraseCollection *tpColl = new TargetPhraseCollection();
|
|
|
|
tpColl->Add(tp);
|
|
|
|
|
|
|
|
m_allTPColl.push_back(tpColl);
|
|
|
|
inputPath.SetTargetPhrases(*this, tpColl, NULL);
|
2013-09-25 01:50:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:57:01 +04:00
|
|
|
TargetPhrase *SkeletonPT::CreateTargetPhrase(const Phrase &sourcePhrase) const
|
|
|
|
{
|
2013-09-27 12:35:24 +04:00
|
|
|
// create a target phrase from the 1st word of the source, prefix with 'SkeletonPT:'
|
2013-11-20 18:02:38 +04:00
|
|
|
assert(sourcePhrase.GetSize());
|
|
|
|
assert(m_output.size() == 1);
|
2013-09-25 22:24:50 +04:00
|
|
|
|
2013-09-27 12:35:24 +04:00
|
|
|
string str = sourcePhrase.GetWord(0).GetFactor(0)->GetString().as_string();
|
|
|
|
str = "SkeletonPT:" + str;
|
2013-09-25 19:57:01 +04:00
|
|
|
|
2013-09-27 12:35:24 +04:00
|
|
|
TargetPhrase *tp = new TargetPhrase();
|
|
|
|
Word &word = tp->AddWord();
|
|
|
|
word.CreateFromString(Output, m_output, str, false);
|
2013-09-25 19:57:01 +04:00
|
|
|
|
2013-09-27 12:35:24 +04:00
|
|
|
// score for this phrase table
|
|
|
|
vector<float> scores(m_numScoreComponents, 1.3);
|
|
|
|
tp->GetScoreBreakdown().PlusEquals(this, scores);
|
2013-09-25 19:57:01 +04:00
|
|
|
|
2013-09-27 12:35:24 +04:00
|
|
|
// score of all other ff when this rule is being loaded
|
|
|
|
tp->Evaluate(sourcePhrase, GetFeaturesToApply());
|
2013-09-25 19:57:01 +04:00
|
|
|
|
2013-09-27 12:35:24 +04:00
|
|
|
return tp;
|
2013-09-25 19:57:01 +04:00
|
|
|
}
|
|
|
|
|
2013-09-25 23:59:13 +04:00
|
|
|
ChartRuleLookupManager* SkeletonPT::CreateRuleLookupManager(const ChartParser &parser,
|
2013-09-27 12:35:24 +04:00
|
|
|
const ChartCellCollectionBase &cellCollection)
|
2013-09-25 01:50:43 +04:00
|
|
|
{
|
2013-09-25 23:59:13 +04:00
|
|
|
return new ChartRuleLookupManagerSkeleton(parser, cellCollection, *this);
|
2013-09-25 01:50:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TO_STRING_BODY(SkeletonPT);
|
|
|
|
|
|
|
|
// friend
|
|
|
|
ostream& operator<<(ostream& out, const SkeletonPT& phraseDict)
|
|
|
|
{
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|