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

Fixed error related to unused default actions

parent 957d17c8
No related branches found
No related tags found
No related merge requests found
...@@ -233,6 +233,9 @@ void Trainer::train() ...@@ -233,6 +233,9 @@ void Trainer::train()
if (pAction == oAction) if (pAction == oAction)
pActionIsZeroCost = true; pActionIsZeroCost = true;
if (oAction.empty())
oAction = tm.getCurrentClassifier()->getDefaultAction();
if (oAction.empty()) if (oAction.empty())
{ {
if (trainConfig.endOfTapes()) if (trainConfig.endOfTapes())
...@@ -241,6 +244,7 @@ void Trainer::train() ...@@ -241,6 +244,7 @@ void Trainer::train()
trainConfig.stackPop(); trainConfig.stackPop();
break; break;
} }
fprintf(stderr, "ERROR (%s) : Unable to find any zero cost action. Aborting.\n", ERRINFO); fprintf(stderr, "ERROR (%s) : Unable to find any zero cost action. Aborting.\n", ERRINFO);
fprintf(stderr, "State : %s\n", tm.getCurrentState().c_str()); fprintf(stderr, "State : %s\n", tm.getCurrentState().c_str());
trainConfig.printForDebug(stderr); trainConfig.printForDebug(stderr);
......
...@@ -77,6 +77,10 @@ class Classifier ...@@ -77,6 +77,10 @@ class Classifier
public : public :
/// @brief If the ActionScript has a default action, get it.
///
/// @return The default action name, or an empty string.
std::string getDefaultAction() const;
/// @brief Return how many errors will an action introduce. /// @brief Return how many errors will an action introduce.
/// ///
/// @param config The current config. /// @param config The current config.
......
...@@ -260,6 +260,14 @@ std::vector<std::string> Classifier::getZeroCostActions(Config & config) ...@@ -260,6 +260,14 @@ std::vector<std::string> Classifier::getZeroCostActions(Config & config)
return result; return result;
} }
std::string Classifier::getDefaultAction() const
{
if (as->hasDefaultAction)
return as->getActionName(0);
return std::string();
}
float Classifier::trainOnExample(Config & config, int gold) float Classifier::trainOnExample(Config & config, int gold)
{ {
auto fd = fm->getFeatureDescription(config); auto fd = fm->getFeatureDescription(config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment