Libraryless. Click here for Pure Java version (3379L/21K).
svoid ai_makeRegexpLanguageDetectorsFromRandomNGrams(S lang1, S lang2, int n) { LanguageDetectionTask task = dm_languageDetectionTask(lang1, lang2); print(task.task()); Set<S> seen = ciSet(); new DynamicTopTen<S> tt; repeat 1000 { S re = firstNotSeen_nAttempts(1000, seen, () -> regexpQuote_useBackslashes(randomNGram(n, random(task.pos))); if (re == null) break with print("Can't find any new regexps"); tt.add(re, scoreRegexpIC(re, task.pos, task.neg)); } pnl(tt.withScores()); dm_saveLanguageDetectionRegexps(task, tt); }
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: | #1027487 |
Snippet name: | ai_makeRegexpLanguageDetectorsFromRandomNGrams |
Eternal ID of this version: | #1027487/1 |
Text MD5: | 54c5d2d8048253126530215ec2b0bc21 |
Transpilation MD5: | 2c53c34e4d41c1c319f6461bf6dfac23 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-22 15:00:22 |
Source code size: | 576 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 176 / 247 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |