mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 15:00:33 +03:00
beautify
This commit is contained in:
parent
2f3cd5e2fe
commit
20b3e8929e
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
@ -604,15 +602,15 @@ int main(int argc, char** argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::cerr <<"Before StaticData::LoadDataStatic" << std::endl;
|
||||
std::cerr <<"Before StaticData::LoadDataStatic" << std::endl;
|
||||
// initialize all "global" variables, which are stored in StaticData
|
||||
// note: this also loads models such as the language model, etc.
|
||||
if (!StaticData::LoadDataStatic(¶ms, argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
std::cerr <<"After StaticData::LoadDataStatic" << std::endl;
|
||||
std::cerr <<"After StaticData::LoadDataStatic" << std::endl;
|
||||
|
||||
std::cerr <<"Before ShowWeights" << std::endl;
|
||||
std::cerr <<"Before ShowWeights" << std::endl;
|
||||
// setting "-show-weights" -> just dump out weights and exit
|
||||
if (params.isParamSpecified("show-weights")) {
|
||||
ShowWeights();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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() ) {
|
||||
|
@ -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;
|
||||
|
@ -77,10 +77,10 @@ void ScoreFeatureManager::configure(const std::vector<std::string> args)
|
||||
}
|
||||
sparseDomainAdded = true;
|
||||
m_includeSentenceId = true;
|
||||
} else if(args[i] == "--TreeFeatureSparse"){
|
||||
} else if(args[i] == "--TreeFeatureSparse") {
|
||||
//MARIA
|
||||
m_features.push_back(ScoreFeaturePtr(new InternalStructFeatureSparse()));
|
||||
} else if(args[i] == "--TreeFeatureDense"){
|
||||
} else if(args[i] == "--TreeFeatureDense") {
|
||||
//MARIA
|
||||
m_features.push_back(ScoreFeaturePtr(new InternalStructFeatureDense()));
|
||||
} else {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user