sparse features in on-disk-pt

This commit is contained in:
Hieu Hoang 2014-06-06 20:35:58 +01:00
parent 0114766b54
commit 747661ba3e
5 changed files with 9 additions and 9 deletions

View File

@ -160,11 +160,11 @@ OnDiskPt::PhrasePtr Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhr
case 5: {
// sparse features
sparseFeatures << tok << " ";
break;
break;
}
case 6: {
property << tok << " ";
break;
property << tok << " ";
break;
}
default:
cerr << "ERROR in line " << line << endl;

View File

@ -31,7 +31,7 @@ using namespace std;
namespace OnDiskPt
{
int OnDiskWrapper::VERSION_NUM = 6;
int OnDiskWrapper::VERSION_NUM = 7;
OnDiskWrapper::OnDiskWrapper()
{

View File

@ -305,14 +305,15 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
// scores
ret->GetScoreBreakdown().Assign(&phraseDict, m_scores);
ret->Evaluate(mosesSP, phraseDict.GetFeaturesToApply());
// sparse features
ret->???(m_sparseFeatures);
ret->GetScoreBreakdown().Assign(&phraseDict, m_sparseFeatures);
// property
ret->SetProperties(m_property);
ret->Evaluate(mosesSP, phraseDict.GetFeaturesToApply());
return ret;
}
@ -354,7 +355,6 @@ UINT64 TargetPhrase::ReadStringFromFile(std::fstream &fileTPColl, std::string &o
fileTPColl.read(mem, strSize);
outStr = string(mem);
free(mem);
cerr << "outStr=" << outStr << endl;
bytesRead += strSize;
}

View File

@ -214,7 +214,7 @@ void ScoreComponentCollection::Save(const string& filename) const
void
ScoreComponentCollection::
Assign(const FeatureFunction* sp, const string line)
Assign(const FeatureFunction* sp, const string &line)
{
istringstream istr(line);
while(istr) {

View File

@ -287,7 +287,7 @@ public:
//Read sparse features from string
void Assign(const FeatureFunction* sp, const std::string line);
void Assign(const FeatureFunction* sp, const std::string &line);
// shortcut: setting the value directly using the feature name
void Assign(const std::string name, float score) {