!7 concept Solver { S code, codeHints; long modified, testedWhen; double score, total; S errorCases; } abstract sclass DynSolvers extends DynCRUD<Solver> { transient S examplesModuleID, inputFieldName, outputFieldName; *() { super(Solver); } start { crud.excludeFieldsFromEditing('testedWhen, 'score, 'total, 'errorCases); crud.multiLineFields = litset('code); crud.modifiedField = 'modified; } afterVisualize { addButton(tableDependentButton(table(), "Test Solver", rThread { testSolver(selected(), scorerWithErrors()) })); addButton(tableDependentButton(table(), "Show Errors", rThread { showText("Errors of solver " + selected().id, sfuLines(safeUnstructList(selected().errorCases))); })); addButton(jPopDownButton_noText("Show Examples", rThread { dm_makeOrShowModule(examplesModuleID) })); } Scorer testSolver(Solver solver, Scorer scorer) enter { O /*F1<S>*/ f = dm_codeWithHintsToFunctionOnString(solver.code, solver.codeHints); L<PairS> examples = dm_importCrudModuleConceptsAsPairs(inputFieldName, outputFieldName, examplesModuleID); cset(solver, score := 0.0, testedWhen := now(), total := l(examples)); for (PairS e : examples) { S got = str(pcallF(f, e.a)); scorer.add(eqic(e.b, got), pair(e, got)); } cset(solver, score := scorer.score, errorCases := struct(scorer.errors)); ret scorer; } // API void addSolver(S code) { uniq_sync(Solver, +code); } }
Began life as a copy of #1020641
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020852 |
Snippet name: | DynSolvers |
Eternal ID of this version: | #1020852/14 |
Text MD5: | 1aa4f2bd8bb9110ed67bed1314596434 |
Author: | stefan |
Category: | javax / stefan's os / nlp |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-05 14:56:05 |
Source code size: | 1536 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 294 / 830 |
Version history: | 13 change(s) |
Referenced in: | [show references] |