1  | !7  | 
2  | |
3  | concept Solver {
 | 
4  | S code, codeHints;  | 
5  | long modified, testedWhen;  | 
6  | double score, total;  | 
7  | S errorCases;  | 
8  | }  | 
9  | |
10  | abstract sclass DynSolvers extends DynCRUD<Solver> {
 | 
11  | transient S examplesModuleID, inputFieldName, outputFieldName;  | 
12  | |
13  |   *() { super(Solver); }
 | 
14  | |
15  |   start {
 | 
16  |     crud.excludeFieldsFromEditing('testedWhen, 'score, 'total, 'errorCases);
 | 
17  |     crud.multiLineFields = litset('code);
 | 
18  | crud.modifiedField = 'modified;  | 
19  | }  | 
20  | |
21  |   afterVisualize {
 | 
22  |     addButton(tableDependentButton(table(), "Test Solver", rThread { testSolver(selected(), scorerWithErrors()) }));
 | 
23  |     addButton(tableDependentButton(table(), "Show Errors", rThread {
 | 
24  |       showText("Errors of solver " + selected().id, sfuLines(safeUnstructList(selected().errorCases)));
 | 
25  | }));  | 
26  |     addButton(jPopDownButton_noText("Show Examples", rThread { dm_makeOrShowModule(examplesModuleID) }));
 | 
27  | }  | 
28  | |
29  |   Scorer testSolver(Solver solver, Scorer scorer) enter {
 | 
30  | O /*F1<S>*/ f = dm_codeWithHintsToFunctionOnString(solver.code, solver.codeHints);  | 
31  | L<PairS> examples = dm_importCrudModuleConceptsAsPairs(inputFieldName, outputFieldName, examplesModuleID);  | 
32  | cset(solver, score := 0.0, testedWhen := now(), total := l(examples));  | 
33  |     for (PairS e : examples) {
 | 
34  | S got = str(pcallF(f, e.a));  | 
35  | scorer.add(eqic(e.b, got), pair(e, got));  | 
36  | }  | 
37  | cset(solver, score := scorer.score, errorCases := struct(scorer.errors));  | 
38  | ret scorer;  | 
39  | }  | 
40  | |
41  | // API  | 
42  | |
43  |   void addSolver(S code) {
 | 
44  | uniq_sync(Solver, +code);  | 
45  | }  | 
46  | }  | 
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: | 536 / 1083 | 
| Version history: | 13 change(s) | 
| Referenced in: | [show references] |