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
Branches
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ struct ProgramParameters ...@@ -15,6 +15,7 @@ struct ProgramParameters
static std::string baseExpName; static std::string baseExpName;
static std::string langPath; static std::string langPath;
static std::string templatePath; static std::string templatePath;
static std::string newTemplatePath;
static std::string templateName; static std::string templateName;
static std::string tmFilename; static std::string tmFilename;
static std::string tmName; static std::string tmName;
......
...@@ -10,6 +10,7 @@ std::string ProgramParameters::baseExpName; ...@@ -10,6 +10,7 @@ std::string ProgramParameters::baseExpName;
std::string ProgramParameters::expPath; std::string ProgramParameters::expPath;
std::string ProgramParameters::langPath; std::string ProgramParameters::langPath;
std::string ProgramParameters::templatePath; std::string ProgramParameters::templatePath;
std::string ProgramParameters::newTemplatePath;
std::string ProgramParameters::templateName; std::string ProgramParameters::templateName;
std::string ProgramParameters::tmFilename; std::string ProgramParameters::tmFilename;
std::string ProgramParameters::tmName; std::string ProgramParameters::tmName;
......
...@@ -135,6 +135,7 @@ void updatePaths() ...@@ -135,6 +135,7 @@ void updatePaths()
ProgramParameters::mcdFilename = ProgramParameters::expPath + ProgramParameters::mcdName; ProgramParameters::mcdFilename = ProgramParameters::expPath + ProgramParameters::mcdName;
ProgramParameters::trainFilename = ProgramParameters::expPath + ProgramParameters::trainName; ProgramParameters::trainFilename = ProgramParameters::expPath + ProgramParameters::trainName;
ProgramParameters::devFilename = ProgramParameters::expPath + ProgramParameters::devName; 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 /// @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 ...@@ -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(("rm -r " + ProgramParameters::expPath + " 2> /dev/null").c_str())){}
if (system(("mkdir " + ProgramParameters::expPath).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(("echo \'" + decode + "\' > " + ProgramParameters::expPath + "decode.sh").c_str())){}
if (system(("chmod +x " + 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())){} if (system(("ln -f -s " + ProgramParameters::expPath + "decode.sh " + ProgramParameters::langPath + "bin/maca_tm_" + ProgramParameters::expName).c_str())){}
...@@ -198,6 +199,18 @@ void launchTraining() ...@@ -198,6 +199,18 @@ void launchTraining()
trainer->train(); 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. /// @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. /// @param argc The number of arguments given to this program.
...@@ -238,6 +251,8 @@ int main(int argc, char * argv[]) ...@@ -238,6 +251,8 @@ int main(int argc, char * argv[])
if (ProgramParameters::nbTrain) if (ProgramParameters::nbTrain)
{ {
updatePaths();
createTemplatePath();
for (int i = 0; i < ProgramParameters::nbTrain; i++) for (int i = 0; i < ProgramParameters::nbTrain; i++)
{ {
fprintf(stderr, "Training number %d / %d :\n", i+1, ProgramParameters::nbTrain); fprintf(stderr, "Training number %d / %d :\n", i+1, ProgramParameters::nbTrain);
...@@ -247,13 +262,16 @@ int main(int argc, char * argv[]) ...@@ -247,13 +262,16 @@ int main(int argc, char * argv[])
Dict::deleteDicts(); Dict::deleteDicts();
launchTraining(); launchTraining();
} }
removeTemplatePath();
} }
else else
{ {
createTemplatePath();
updatePaths(); updatePaths();
createExpPath(); createExpPath();
Dict::deleteDicts(); Dict::deleteDicts();
launchTraining(); launchTraining();
removeTemplatePath();
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment