Uses 911K of libraries. Click here for Pure Java version (12262L/63K).
!7 concept DetectorEntry { S task; // e.g. "English vs German n=1000" S expression; // posNgram|posNgram|...^negNgram|negNgram|... S result; // double (0..1) } cmodule LanguageDetectionNGramScorers > DynCRUD<DetectorEntry> { start { indexConceptFieldsCI(DetectorEntry, 'task, DetectorEntry, 'expression); crud.sorter = func(Cl<DetectorEntry> l) -> L<DetectorEntry> { sortByCalculatedFieldDesc(l, e -> pair(parseDoubleOpt(e.result), -l(e.expression))) }; crud.renderer = func(DetectorEntry e) -> Map { litorderedmap( "Expression" := e.expression, "Result / Length" := e.result + " / " + l(e.expression), "Task" := e.task) }; } // API void saveResult(S task, S expression, S result) { cset(uniqCI DetectorEntry(+expression, +task), +result); } // pairs of expression + result LPairS expressionsForTask(S task) { ret map(conceptsWhereCI DetectorEntry(+task), e -> pair(e.expression, e.result)); } LS expressionsForTaskByScore(S task) { ret pairsA(sortedByCalculatedFieldDesc(expressionsForTask(task), p -> parseDoubleOpt(p.b))); } }
Began life as a copy of #1027460
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027488 |
Snippet name: | Language Detection N-Gram-Scorer CRUD |
Eternal ID of this version: | #1027488/13 |
Text MD5: | f5f249afce2a1d2c046cbecae5ce3ce3 |
Transpilation MD5: | 4850148dd8ee92f76e99319ef167d591 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-22 16:52:28 |
Source code size: | 1187 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 225 / 566 |
Version history: | 12 change(s) |
Referenced in: | #1027489 - dm_languageDetectionNGramScorersCRUD |