diff --git a/maca_common/include/ProgramParameters.hpp b/maca_common/include/ProgramParameters.hpp index 5f0a5e491fa63a7b7f0c53211dbf681199563724..0ee0d9df5f9829a94b4f0081c8252e0cff7f5af1 100644 --- a/maca_common/include/ProgramParameters.hpp +++ b/maca_common/include/ProgramParameters.hpp @@ -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; diff --git a/maca_common/src/ProgramParameters.cpp b/maca_common/src/ProgramParameters.cpp index c84bf7cd82ba41e02b05dbf830465323990f21c8..b505d043058734022436c33fea72cd8fdf6cde22 100644 --- a/maca_common/src/ProgramParameters.cpp +++ b/maca_common/src/ProgramParameters.cpp @@ -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; diff --git a/trainer/src/macaon_train.cpp b/trainer/src/macaon_train.cpp index 3505310cbc7c99f1f6cdf00b4fa4e7292def445a..e96de4caf1e2a08f84a556da884dcb015fde0f8b 100644 --- a/trainer/src/macaon_train.cpp +++ b/trainer/src/macaon_train.cpp @@ -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;