Download Jar. Uses 3874K of libraries. Click here for Pure Java version (13661L/97K).
!7 concept Example { S input; Triple<S> triple; transient Triple<S> guessed; } static F1<S, Triple<S>> guesser; static JLabel lblStatus; static Map<S, Triple<S>> examples, errors; p-subst { dbIndexing(Example, 'input); autoRestart(); for (S s : keys(gac36k())) uniq(Example, input := s); print("Making CRUD"); sexyTable_drag = false; final SimpleCRUD<Example> crud = new SimpleCRUD<Example>(Example) { void saveComponent(Example c, S field, JComponent comp) { if (eqOneOf(field, 'triple, 'guessed)) cset(c, field, unstructureOrNull(getTextTrim(comp))); else super.saveComponent(c, field, comp); } }; crud.renderer = func(Example e) { litorderedmap(Input := e.input, Triple := ai_tripleToString(e.triple), Guessed := ai_tripleToString(e.guessed)) }; crud.showMaximized(); swing { tablePopupMenuItemFirst(crud.table, "Accept", voidfunc(int row) { for (Example e : crud.selectedConcepts()) cset(e, triple := e.guessed); }); containerAddFirst(crud.buttons, /*jbutton("Set multi...", r { final L<Example> l = crud.selectedConcepts(); showTextFieldForm("Set multi (" + l(l) + ")", "Verb", first(l).verb_guessed, voidfunc(S s) { for (Example e : l) cset(e, verb := s); }); }),*/ jbutton("Show errors", f showErrors)); containerAddFirst(crud.buttons, jbutton("Clear caches", f clearAllCaches)); } addToFrame(crud.panel, lblStatus = jlabel()); thread { guessLoop(); } } static Map<S, Triple<S>> examples() { ret mapFromKeyAndValueField([Example e : list(Example) | e.triple != null], 'input, 'triple); } svoid guessLoop { repeat with sleep 5 { int changes = 0; new HashMap<S, Triple<S>> guessedMap; Window anim = miniLoadingAnim(); try { examples = examples(); int nTrain = l(examples)/2; Map<S, Triple<S>> trainExamples = keysToMap(examples, selectRandom_fast(keysList(examples), nTrain)); guesser = new F1<S, Triple<S>>() { Triple<S> get(S s) { ret ai_tripelize(unquoteIfNotContainingOtherQuotes(s)); } }; for (Example e) { Triple<S> t = (Triple<S>) pcallF(guesser, e.input); changes += cset(e, guessed := t); guessedMap.put(e.input, t); } if (changes > 0) change(); Pair<Double, Map<S, Triple<S>>> p = scoreTripelizer(mapGetter(guessedMap), examples); double score = p.a; errors = p.b; setText(lblStatus, n(examples, "example") + ", trained with " + l(trainExamples) + ", score: " + formatDouble(score*100, 1) + "% (" + iround((1-score)*l(examples)) + " missing)"); } finally { disposeWindow(anim); } } } svoid showErrors { showTable(map(keys(errors), func(S input) { litorderedmap(Input := input, Real := ai_tripleToString(examples.get(input)), Guessed := ai_tripleToString(errors.get(input))) }), "Errors"); }
Began life as a copy of #1011018
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011085 |
Snippet name: | Train Tripelizer [OK] |
Eternal ID of this version: | #1011085/16 |
Text MD5: | b03547f870e1b14776e00f51bb759c6a |
Transpilation MD5: | 7db6b193230b856697bb65b1e2c5b841 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-25 21:10:06 |
Source code size: | 3060 bytes / 97 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 624 / 3139 |
Version history: | 15 change(s) |
Referenced in: | #3000512 - Smart Bot's answer to: !eval centralRestartLog_raw() |