Download Jar. Uses 3981K of libraries. Click here for Pure Java version (15153L/115K).
!7 static double zoom = 1.5; static volatile BufferedImage img, recognizedImage; static L<RecognizedText> texts; static ImageSurface is, isWord; static volatile int score; static volatile L<RecognizedText> posTexts, negTexts; static Set<S> dontPrint; sbool scoreBox; static int coresToUse = 1; p-subst-autorestart { run(#1015409); ocr_recognizeMultiLine_scored_maxPixels = 20000; hideConsoleOnFirstFrame(); dontPrint = mechSetCI("Movie Review Cat | Negative/positive words don't print list"); thread "The Loop" { theLoop(); } noMainDone("Cat!"); } svoid theLoop { repeat with sleep 0 { temp tempSetCoresToUse(coresToUse); img = shootScreen2(); long recTime = sysNow(); assertEquals("Cores to use", coresToUse, coresToUse_fixed()); texts = ocr_recognizeMultiLine_scored(img); print(filledSimpleRecognizer_cached().cacheStats()); recTime = sysNow()-recTime; time "Post" { MultiSet<S> multiSet = asCIMultiSet(words(lines(mapMethod('text, texts)))); Set<S> positiveWords = mechSetCI("Movie Review Cat | Positive words"); Set<S> negativeWords = mechSetCI("Movie Review Cat | Negative words"); final MultiSet<S> plus = multiSetSetIntersection(multiSet, positiveWords); final MultiSet<S> minus = multiSetSetIntersection(multiSet, negativeWords); score = l(plus)-l(minus); posTexts = [RecognizedText r : texts | containsOneOfTheWords(r.text(), setMinusSet(keys(plus), dontPrint))]; negTexts = [RecognizedText r : texts | containsOneOfTheWords(r.text(), setMinusSet(keys(minus), dontPrint))]; L<S> popPlus = mostPopularEntriesFromMultiMap(3, plus); L<S> popMinus = mostPopularEntriesFromMultiMap(3, minus); S text = "Score: " + score; if (scoreBox) { if (score >= 0 && nempty(popPlus)) text += "\n" + joinWithComma(popPlus); if (score <= 0 && nempty(popMinus)) text += "\n" + joinWithComma(popMinus); flatInfoBox(recTime + " ms | " + escapeNewLines(text)); } S imageID = minusZeroPlus(score, #1101254, #1101256, #1101255); recognizedImage = img; } bool first = is == null; is = showImage_hcentered(is, "Movie Review Cat!", loadImage2_cached(imageID)); if (first) { setDoubleBuffered(is, true); frameTitlePopupMenu(is, voidfunc(JPopupMenu menu) { menu.add(boolFieldMenuItem(mc(), 'scoreBox)); menu.add(intFieldMenuItem(mc(), 'coresToUse)); }); alwaysOnTopFrame(is); addToWindowWithMargin(is, jfullcenter(isWord = jImageSurface())); enlargeFrameLeftAndBottom(is, 50); isWord.setZoom(2); awtEvery(isWord, 333, f cycleWord); } } } svoid cycleWord { if (recognizedImage == null) ret; RecognizedText hilite = random(score > 0 ? posTexts : score < 0 ? negTexts : null); if (hilite != null) { BufferedImage clip = clipBufferedImage(recognizedImage, hilite.r); isWord.setImage(clip); showZoomedScreenClipInPlace(hilite.r, clip, zoom, 0.5); } else isWord.setImage(newBufferedImage(1, 1, Color.white)); }
Began life as a copy of #1015422
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, vpdwwinrgdga
No comments. add comment
Snippet ID: | #1015468 |
Snippet name: | Movie Review Cat [shortened] |
Eternal ID of this version: | #1015468/17 |
Text MD5: | 4fa2d740b3547863d0fefc2f4b63c487 |
Transpilation MD5: | 615316c4a7174fb0506621962237444b |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-31 03:35:39 |
Source code size: | 3172 bytes / 82 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 491 / 1142 |
Version history: | 16 change(s) |
Referenced in: | -