-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: make scorer part of evaluator as helper
- Loading branch information
Showing
67 changed files
with
854 additions
and
1,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#pragma once | ||
|
||
#include "tcframe/evaluator/BatchEvaluator.hpp" | ||
#include "tcframe/evaluator/EvaluationResult.hpp" | ||
#include "tcframe/evaluator/Evaluator.hpp" | ||
#include "tcframe/evaluator/EvaluatorConfig.hpp" | ||
#include "tcframe/evaluator/EvaluatorFactory.hpp" | ||
#include "tcframe/evaluator/GenerationResult.hpp" | ||
#include "tcframe/evaluator/scorer.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <string> | ||
#include <tuple> | ||
|
||
#include "tcframe/os.hpp" | ||
#include "tcframe/util.hpp" | ||
#include "tcframe/verdict.hpp" | ||
|
||
using std::map; | ||
using std::string; | ||
using std::tie; | ||
|
||
namespace tcframe { | ||
|
||
struct EvaluationResult { | ||
private: | ||
Verdict verdict_; | ||
map<string, ExecutionResult> executionResults_; | ||
|
||
public: | ||
EvaluationResult(const Verdict& verdict, const map<string, ExecutionResult>& executionResults) | ||
: verdict_(verdict) | ||
, executionResults_(executionResults) {} | ||
|
||
const Verdict& verdict() const { | ||
return verdict_; | ||
} | ||
|
||
const map<string, ExecutionResult>& executionResults() const { | ||
return executionResults_; | ||
} | ||
|
||
bool operator==(const EvaluationResult& o) const { | ||
return tie(verdict_, executionResults_) == tie(o.verdict_, o.executionResults_); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "BatchEvaluator.hpp" | ||
#include "Evaluator.hpp" | ||
#include "scorer.hpp" | ||
#include "tcframe/os.hpp" | ||
#include "tcframe/util.hpp" | ||
#include "tcframe/verdict.hpp" | ||
|
||
using std::string; | ||
|
||
namespace tcframe { | ||
|
||
class EvaluatorFactory { | ||
public: | ||
virtual ~EvaluatorFactory() {} | ||
|
||
virtual Evaluator* createBatch(OperatingSystem* os, const optional<string>& scorerCommand) { | ||
VerdictCreator* verdictCreator = new VerdictCreator(); | ||
Scorer* scorer; | ||
if (scorerCommand) { | ||
scorer = new CustomScorer(os, verdictCreator, scorerCommand.value()); | ||
} else { | ||
scorer = new DiffScorer(os); | ||
} | ||
|
||
return new BatchEvaluator(os, verdictCreator, scorer); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <tuple> | ||
|
||
#include "tcframe/os.hpp" | ||
#include "tcframe/util.hpp" | ||
#include "tcframe/verdict.hpp" | ||
|
||
using std::tie; | ||
|
||
namespace tcframe { | ||
|
||
struct GenerationResult { | ||
private: | ||
optional<Verdict> verdict_; | ||
ExecutionResult executionResult_; | ||
|
||
public: | ||
GenerationResult(const optional<Verdict>& verdict, const ExecutionResult& executionResult) | ||
: verdict_(verdict) | ||
, executionResult_(executionResult) {} | ||
|
||
const optional<Verdict>& verdict() const { | ||
return verdict_; | ||
} | ||
|
||
const ExecutionResult& executionResult() const { | ||
return executionResult_; | ||
} | ||
|
||
bool operator==(const GenerationResult& o) const { | ||
return tie(verdict_, executionResult_) == tie(o.verdict_, o.executionResult_); | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.