add parameter argument -feature-add for mira BLEU score feature

This commit is contained in:
Hieu Hoang 2013-08-13 15:34:03 +01:00
parent 02c7af3fb8
commit aa7eabf850
6 changed files with 26 additions and 3 deletions

View File

@ -85,6 +85,7 @@
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="z"/>
<listOptionValue builtIn="false" value="bz2"/>
<listOptionValue builtIn="false" value="rt"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.128214028" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>

View File

@ -81,6 +81,7 @@
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="z"/>
<listOptionValue builtIn="false" value="bz2"/>
<listOptionValue builtIn="false" value="rt"/>
</option>
<option id="gnu.cpp.link.option.userobjs.1542590830" name="Other objects" superClass="gnu.cpp.link.option.userobjs"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.983725033" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">

View File

@ -64,6 +64,7 @@ MosesDecoder::MosesDecoder(const string& inifile, int debuglevel, int argc, vect
for (int i = 0; i < argc; ++i) {
char *cstr = &(decoder_params[i])[0];
mosesargv[BASE_ARGC + i] = cstr;
//cerr << "cstr=" << cstr << endl;
}
if (!params->LoadParam(BASE_ARGC + argc,mosesargv)) {

View File

@ -398,7 +398,7 @@ int main(int argc, char** argv)
// initialise Moses
// add references to initialize Bleu feature
boost::trim(decoder_settings);
decoder_settings += " -mira -n-best-list - " + boost::lexical_cast<string>(n) + " distinct -weight-bl 1 -references";
decoder_settings += " -mira -n-best-list - " + boost::lexical_cast<string>(n) + " distinct -feature-add \"BleuScoreFeature tuneable=false\" -references";
if (trainWithMultipleFolds) {
decoder_settings += " ";
decoder_settings += referenceFilesFolds[myFold];

View File

@ -193,9 +193,10 @@ Parameter::Parameter()
AddParam("weight", "weights for ALL models, 1 per line 'WeightName value'. Weight names can be repeated");
AddParam("weight-overwrite", "special parameter for mert. All on 1 line. Overrides weights specified in 'weights' argument");
AddParam("feature-overwrite", "Override arguments in a particular featureu function with a particular key");
AddParam("feature-overwrite", "Override arguments in a particular feature function with a particular key");
AddParam("feature-add", "Add a feature function on the command line. Used by mira to add BLEU feature");
AddParam("feature", "");
AddParam("feature", "All the feature functions should be here");
AddParam("print-id", "prefix translations with id. Default if false");
AddParam("alternate-weight-setting", "aws", "alternate set of weights to used per xml specification");
@ -295,6 +296,8 @@ bool Parameter::LoadParam(int argc, char* argv[])
OverwriteParam("-" + paramShortName, paramName, argc, argv);
}
AddFeaturesCmd();
// logging of parameters that were set in either config or switch
int verbose = 1;
if (m_setting.find("verbose") != m_setting.end() &&
@ -355,6 +358,22 @@ bool Parameter::LoadParam(int argc, char* argv[])
return Validate() && noErrorFlag;
}
void Parameter::AddFeaturesCmd()
{
if (!isParamSpecified("feature-add")) {
return;
}
const PARAM_VEC &params = GetParam("feature-add");
PARAM_VEC::const_iterator iter;
for (iter = params.begin(); iter != params.end(); ++iter) {
const string &line = *iter;
AddFeature(line);
}
}
std::vector<float> &Parameter::GetWeights(const std::string &name)
{
std::vector<float> &ret = m_weights[name];

View File

@ -76,6 +76,7 @@ protected:
void CreateWeightsMap();
void WeightOverwrite();
void AddFeature(const std::string &line);
void AddFeaturesCmd();
public: