Skip to content
Snippets Groups Projects
Commit 41db42dc authored by Franck Dary's avatar Franck Dary
Browse files

Corrected a bug where multiple train of the same exp could be launched with different parameters

parent 4876271c
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ struct ProgramParameters
static std::string baseExpName;
static std::string langPath;
static std::string templatePath;
static std::string newTemplatePath;
static std::string templateName;
static std::string tmFilename;
static std::string tmName;
......
......@@ -10,6 +10,7 @@ std::string ProgramParameters::baseExpName;
std::string ProgramParameters::expPath;
std::string ProgramParameters::langPath;
std::string ProgramParameters::templatePath;
std::string ProgramParameters::newTemplatePath;
std::string ProgramParameters::templateName;
std::string ProgramParameters::tmFilename;
std::string ProgramParameters::tmName;
......
......@@ -135,6 +135,7 @@ void updatePaths()
ProgramParameters::mcdFilename = ProgramParameters::expPath + ProgramParameters::mcdName;
ProgramParameters::trainFilename = ProgramParameters::expPath + ProgramParameters::trainName;
ProgramParameters::devFilename = ProgramParameters::expPath + ProgramParameters::devName;
ProgramParameters::newTemplatePath = ProgramParameters::langPath + "bin/" + ProgramParameters::baseExpName + slash;
}
/// @brief Create the folder containing the current experiment from the template frolder
......@@ -163,7 +164,7 @@ macaon_decode --lang $LANG --tm machine.tm --bd test.bd -I $INPUT --mcd $MCD --e
if (system(("rm -r " + ProgramParameters::expPath + " 2> /dev/null").c_str())){}
if (system(("mkdir " + ProgramParameters::expPath).c_str())){}
if (system(("cp -r " + ProgramParameters::templatePath + "* " + ProgramParameters::expPath + ".").c_str())){}
if (system(("cp -r " + ProgramParameters::newTemplatePath + "* " + ProgramParameters::expPath + ".").c_str())){}
if (system(("echo \'" + decode + "\' > " + ProgramParameters::expPath + "decode.sh").c_str())){}
if (system(("chmod +x " + ProgramParameters::expPath + "decode.sh").c_str())){}
if (system(("ln -f -s " + ProgramParameters::expPath + "decode.sh " + ProgramParameters::langPath + "bin/maca_tm_" + ProgramParameters::expName).c_str())){}
......@@ -198,6 +199,18 @@ void launchTraining()
trainer->train();
}
void createTemplatePath()
{
if (system(("rm -r " + ProgramParameters::newTemplatePath + " 2> /dev/null").c_str())){}
if (system(("mkdir " + ProgramParameters::newTemplatePath).c_str())){}
if (system(("cp -r " + ProgramParameters::templatePath + "* " + ProgramParameters::newTemplatePath + ".").c_str())){}
}
void removeTemplatePath()
{
if (system(("rm -r " + ProgramParameters::newTemplatePath + " 2> /dev/null").c_str())){}
}
/// @brief Train a TransitionMachine to predict and add information to a structured input file, by using annotated examples.
///
/// @param argc The number of arguments given to this program.
......@@ -238,6 +251,8 @@ int main(int argc, char * argv[])
if (ProgramParameters::nbTrain)
{
updatePaths();
createTemplatePath();
for (int i = 0; i < ProgramParameters::nbTrain; i++)
{
fprintf(stderr, "Training number %d / %d :\n", i+1, ProgramParameters::nbTrain);
......@@ -247,13 +262,16 @@ int main(int argc, char * argv[])
Dict::deleteDicts();
launchTraining();
}
removeTemplatePath();
}
else
{
createTemplatePath();
updatePaths();
createExpPath();
Dict::deleteDicts();
launchTraining();
removeTemplatePath();
}
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment