Download Jar. Uses 3874K of libraries. Click here for Pure Java version (13300L/95K).
!7 concept Example { S input; S verb; transient S verb_guessed; } static F1<S, S> guesser; static JLabel lblStatus; static SS 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 = simpleCRUD(Example); swing { tablePopupMenuItemFirst(crud.table, "Accept", voidfunc(int row) { for (Example e : crud.selectedConcepts()) cset(e, verb := e.verb_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)); } addToFrame(crud.panel, lblStatus = jlabel()); thread { guessLoop(); } } static SS examples() { ret mapFromKeyAndValueField([Example e : list(Example) | nempty(e.verb)], 'input, 'verb); } svoid guessLoop { repeat with sleep 5 { int changes = 0; new HashMap<S> guessedMap; Window anim = miniLoadingAnim(); try { examples = examples(); int nTrain = l(examples)/2; SS trainExamples = keysToMap(examples, selectRandom_fast(keysList(examples), nTrain)); //guesser = cheatGuesser(trainExamples); guesser = new F1<S, S>() { S get(S s) { s = unquoteIfNotContainingOtherQuotes(s); try answer ai_guessVerb(s); //ret firstWordPlusQuestionMark(s); null; } }; for (Example e) { S s = unnullStr(pcallF(guesser, e.input)); changes += cset(e, verb_guessed := s); guessedMap.put(e.input, s); } if (changes > 0) change(); Pair<Double, SS> p = scoreGuesserIC_1_returnErrors(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, Verb := examples.get(input), Guessed := errors.get(input)) }), "Errors"); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011018 |
Snippet name: | Train GAC-36K parser [OK] |
Eternal ID of this version: | #1011018/43 |
Text MD5: | fe75b44a32d514815660b61d7ba76fbb |
Transpilation MD5: | 07b69dec1da3b06f05fb0cd1ceb89d3c |
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-12 02:32:35 |
Source code size: | 2527 bytes / 88 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 582 / 3552 |
Version history: | 42 change(s) |
Referenced in: | [show references] |