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

Improved featureExtraction

parent 5fd8f5e6
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@ void Trainer::computeScoreOnDev()
else
{
// Print current iter advancement in percentage
if (ProgramParameters::interactive && !ProgramParameters::featureExtraction)
if (ProgramParameters::interactive)
{
int totalSize = ProgramParameters::devTapeSize;
int steps = devConfig->getHead();
......@@ -223,7 +223,7 @@ void Trainer::doStepTrain()
}
// Print current iter advancement in percentage
if (ProgramParameters::interactive && !ProgramParameters::featureExtraction)
if (ProgramParameters::interactive)
{
int totalSize = ProgramParameters::iterationSize == -1 ? ProgramParameters::tapeSize : ProgramParameters::iterationSize;
int steps = ProgramParameters::iterationSize == -1 ? trainConfig.getHead() : nbSteps;
......@@ -298,7 +298,7 @@ void Trainer::doStepTrain()
if (ProgramParameters::featureExtraction)
{
auto features = tm.getCurrentClassifier()->getFeatureModel()->getFeatureDescription(trainConfig).featureValues();
fprintf(stdout, "%s\t%s\n", oAction.c_str(), features.c_str());
fprintf(stdout, "%s\t%s\t%s\n", tm.getCurrentClassifier()->getFeatureModel()->filename.c_str(), oAction.c_str(), features.c_str());
}
if (TI.getEpoch() >= k && choiceWithProbability(ProgramParameters::dynamicProbability))
......
......@@ -103,6 +103,11 @@ class FeatureModel
public :
/// @brief The name of the FeatureModel file.
std::string filename;
public :
/// @brief Tranform a Policy into the corresponding string.
///
/// @param policy The Policy.
......
......@@ -21,6 +21,8 @@ FeatureModel::FeatureDescription & FeatureModel::getFeatureDescription(Config &
FeatureModel::FeatureModel(const std::string & filename)
{
this->filename = getFilenameFromPath(filename);
File file(filename, "r");
FILE * fd = file.getDescriptor();
char buffer[1024];
......@@ -141,8 +143,8 @@ std::string FeatureModel::FeatureDescription::featureValues()
std::string res;
for (auto & feature : values)
for (auto & value : feature.values)
res += value + "\t";
for (unsigned int i = 0; i < feature.values.size(); i++)
res += feature.values[i] + (i == feature.values.size()-1 ? "\t" : " ");
if (!res.empty())
res.pop_back();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment