This commit is contained in:
Nicola Bertoldi 2014-05-19 15:35:08 +02:00
parent 2f3cd5e2fe
commit 20b3e8929e
17 changed files with 240 additions and 234 deletions

View File

@ -34,7 +34,8 @@ namespace MosesTuning
#define CHILD_STDOUT_WRITE pipefds_output[1]
MeteorScorer::MeteorScorer(const string& config)
: StatisticsBasedScorer("METEOR",config) {
: StatisticsBasedScorer("METEOR",config)
{
meteor_jar = getConfig("jar", "");
meteor_lang = getConfig("lang", "en");
meteor_task = getConfig("task", "tune");
@ -88,7 +89,8 @@ MeteorScorer::MeteorScorer(const string& config)
m_from_meteor = new ifdstream(CHILD_STDOUT_READ);
}
MeteorScorer::~MeteorScorer() {
MeteorScorer::~MeteorScorer()
{
// Cleanup IO
delete m_to_meteor;
delete m_from_meteor;
@ -171,7 +173,8 @@ float MeteorScorer::calculateScore(const vector<int>& comps) const
// Meteor unsupported, throw error if used
MeteorScorer::MeteorScorer(const string& config)
: StatisticsBasedScorer("METEOR",config) {
: StatisticsBasedScorer("METEOR",config)
{
throw runtime_error("Meteor unsupported, requires GLIBCXX");
}

View File

@ -234,8 +234,7 @@ static void ShowWeights()
const StatefulFeatureFunction *ff = sff[i];
if (ff->IsTuneable()) {
PrintFeatureWeight(ff);
}
else {
} else {
cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
}
}
@ -243,8 +242,7 @@ static void ShowWeights()
const StatelessFeatureFunction *ff = slf[i];
if (ff->IsTuneable()) {
PrintFeatureWeight(ff);
}
else {
} else {
cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
}
}

View File

@ -504,8 +504,7 @@ static void ShowWeights()
const StatefulFeatureFunction *ff = sff[i];
if (ff->IsTuneable()) {
PrintFeatureWeight(ff);
}
else {
} else {
cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
}
}
@ -513,8 +512,7 @@ static void ShowWeights()
const StatelessFeatureFunction *ff = slf[i];
if (ff->IsTuneable()) {
PrintFeatureWeight(ff);
}
else {
} else {
cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
}
}

View File

@ -29,7 +29,8 @@
using namespace std;
namespace MosesTraining {
namespace MosesTraining
{
extern Vocabulary vcbT;
@ -64,7 +65,8 @@ ExtractionPhrasePair::ExtractionPhrasePair( const PHRASE *phraseSource,
}
ExtractionPhrasePair::~ExtractionPhrasePair( ) {
ExtractionPhrasePair::~ExtractionPhrasePair( )
{
Clear();
}

View File

@ -24,13 +24,15 @@
#include <set>
#include <map>
namespace MosesTraining {
namespace MosesTraining
{
typedef std::vector< std::set<size_t> > ALIGNMENT;
class ExtractionPhrasePair {
class ExtractionPhrasePair
{
protected:
@ -126,8 +128,7 @@ public:
void AddProperties( const std::string &str, float count );
void AddProperty( const std::string &key, const std::string &value, float count )
{
void AddProperty( const std::string &key, const std::string &value, float count ) {
std::map<std::string,
std::pair< PROPERTY_VALUES*, LAST_PROPERTY_VALUE* > >::iterator iter = m_properties.find(key);
if ( iter == m_properties.end() ) {

View File

@ -8,7 +8,8 @@ namespace MosesTraining
void InternalStructFeature::add(const ScoreFeatureContext& context,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const {
std::map<std::string,float>& sparseValues) const
{
const std::map<std::string,float> *allTrees = context.phrasePair.GetProperty("Tree"); // our would we rather want to take the most frequent one only?
for ( std::map<std::string,float>::const_iterator iter=allTrees->begin();
iter!=allTrees->end(); ++iter ) {
@ -19,7 +20,8 @@ void InternalStructFeature::add(const ScoreFeatureContext& context,
void InternalStructFeatureDense::add(const std::string *treeFragment,
float count,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const {
std::map<std::string,float>& sparseValues) const
{
//cout<<"Dense: "<<*internalStruct<<endl;
size_t start=0;
int countNP=0;
@ -36,7 +38,8 @@ void InternalStructFeatureDense::add(const std::string *treeFragment,
void InternalStructFeatureSparse::add(const std::string *treeFragment,
float count,
std::vector<float>& denseValues,
std::map<std::string,float>& sparseValues) const {
std::map<std::string,float>& sparseValues) const
{
//cout<<"Sparse: "<<*internalStruct<<endl;
if(treeFragment->find("VBZ")!=std::string::npos)
sparseValues["NTVBZ"] += count;

View File

@ -608,11 +608,9 @@ int getClass(const std::string &str)
size_t pos = str.find("swap");
if (pos == str.npos) {
return 0;
}
else if (pos == 0) {
} else if (pos == 0) {
return 1;
}
else {
} else {
return 2;
}
}

View File

@ -295,7 +295,9 @@ int main(int argc, char* argv[])
tmpCount, tmpPcfgSum);
bool matchesPrevious = false;
bool sourceMatch = true; bool targetMatch = true; bool alignmentMatch = true; // be careful with these,
bool sourceMatch = true;
bool targetMatch = true;
bool alignmentMatch = true; // be careful with these,
// ExtractionPhrasePair::Matches() checks them in order and does not continue with the others
// once the first of them has been found to have to be set to false
@ -889,7 +891,8 @@ void printTargetPhrase(const PHRASE *phraseSource, const PHRASE *phraseTarget,
void invertAlignment(const PHRASE *phraseSource, const PHRASE *phraseTarget,
const ALIGNMENT *inTargetToSourceAlignment, ALIGNMENT *outSourceToTargetAlignment) {
const ALIGNMENT *inTargetToSourceAlignment, ALIGNMENT *outSourceToTargetAlignment)
{
// typedef std::vector< std::set<size_t> > ALIGNMENT;
outSourceToTargetAlignment->clear();