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

Added other tools for score computation

parent 80251897
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ class TrainInfos
void saveToFilename();
void addTrainScore(const std::string & classifier, float score);
void addDevScore(const std::string & classifier, float score);
float computeScoreOnTapes(Config & c, std::vector<std::string> tapes);
public :
......
......@@ -143,16 +143,32 @@ void TrainInfos::addDevScore(const std::string & classifier, float score)
devScoresPerClassifierPerEpoch[classifier].emplace_back(score);
}
float TrainInfos::computeScoreOnTapes(Config & c, std::vector<std::string> tapes)
{
float res = 0.0;
for (auto & tape : tapes)
res += c.getTape(tape).getScore();
return res / tapes.size();
}
void TrainInfos::computeTrainScores(Config & c)
{
for (auto & it : topologyPrinted)
{
if (it.first == "Parser")
addTrainScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}));
else if (it.first == "Tagger")
addTrainScore(it.first, computeScoreOnTapes(c, {"POS"}));
else if (it.first == "Morpho")
addTrainScore(it.first, computeScoreOnTapes(c, {"MORPHO"}));
else if (it.first == "Lemmatizer_Rules")
addTrainScore(it.first, computeScoreOnTapes(c, {"LEMMA"}));
else
{
float govScore = c.getTape("GOV").getScore();
float labelScore = c.getTape("LABEL").getScore();
float score = (govScore + labelScore) / 2;
addTrainScore(it.first, score);
fprintf(stderr, "ERROR (%s) : No instructions to compute score of tool \'%s\'. Aborting.\n", ERRINFO, it.first.c_str());
exit(1);
}
}
}
......@@ -162,11 +178,19 @@ void TrainInfos::computeDevScores(Config & c)
for (auto & it : topologyPrinted)
{
if (it.first == "Parser")
addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}));
else if (it.first == "Parser")
addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}));
else if (it.first == "Tagger")
addDevScore(it.first, computeScoreOnTapes(c, {"POS"}));
else if (it.first == "Morpho")
addDevScore(it.first, computeScoreOnTapes(c, {"MORPHO"}));
else if (it.first == "Lemmatizer_Rules")
addDevScore(it.first, computeScoreOnTapes(c, {"LEMMA"}));
else
{
float govScore = c.getTape("GOV").getScore();
float labelScore = c.getTape("LABEL").getScore();
float score = (govScore + labelScore) / 2;
addDevScore(it.first, score);
fprintf(stderr, "ERROR (%s) : No instructions to compute score of tool \'%s\'. Aborting.\n", ERRINFO, it.first.c_str());
exit(1);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment