I don't know why this bothers me as much as it does, but I did find len((raw[0])) hidden in there.
If you want to save the extra three characters to alias range to r_, why use range again in line 57?
This is the code with some improved formatting:
def d31(raw):
return(lambda _ : _[0] * _[1])(
[
int(
''.join(
[
f(set(e), key=e.count) for e in [
(
[_[e] for _ in raw]
) for e in range(len(raw[0]))
]
]
), 2
) for f in (max, min)
]
)
def _sp(p, g, a='c', b='d', c='a', d='b'):
if p[a] > p[b]:
p[a], p[b], p[c], p[d] = p[b], p[a], p[d], p[c]
for _ in range(p[a], p[b]+1):
if a == 'c':
g[_][p[c]] += 1
else:
g[p[c]][_] += 1
# draw positions on board
def d31(raw):
return(lambda _:_[0]*_[1])([i_(''.join([f(set(e),key=e.count)for e in[([_[e]for _ in raw])for e in range(len((raw[0])))]]),2)for f in(max,min)])
def _sp(p,g,a="c",b="d",c="a",d="b"):
if p[a]>p[b]:p[a],p[b],p[c],p[d]=p[b],p[a],p[d],p[c]
for _ in r_(p[a],p[b]+1):
if a=="c":g[_][p[c]]+=1
else:g[p[c]][_]+=1
I did it manually. OCR is, unfortunately, currently infeasible for transcriptions such as this.
It can, and does, easily get a lot wrong. It's most accurate on simple screenshots of social media, such as Twitter, but even there will mess up occasionally. The bot we have on r/TranscribersOfReddit uses one of the best API's in the world, but even it is not immune to errors. Since we're providing an accessibility service, we can't rely on something like that; we need as close to 100% accuracy as possible.
Code, specifically, is actually some of the worst work OCR does. Most large and publically available OCR API's are trained specifically on non-monospace fonts, as these are more common, making the API useful in a wider variety of scenarios. As a result, they often misinterpret characters in code, lose the indentation, and sometimes even skip over things completely. Generally, it's just as much work to correct what the OCR has done as it is to do the post manually.
In some respects; some of the character misinterpretations would probably still happen (the dot in the monospace 0 is often confused for Ø and vice versa, even in very advanced algorithms). It would also be a lot of work to specifically make it work well with Reddit's formatting, to avoid having to still manually re-jig everything for that.
At the end of the day, though, we have one bot, with one API, and that's all we have the resources for. We're a relatively small non-profit and don't have the team or the time to develop a new OCR algorithm, or the resources to run a second bot or pay for a second API, and given that code posts are comparatively quite rare, we need to use an API that works well for non-monospace text.
Unfortunately, I have colleagues who like to code like this. Whenever I have to debug their stuff, I have to rewrite their code first, so that you can actually debug it.
101
u/LSatyreD Jan 26 '22
To make it better:
i_is globally defined toint, and,r_torange36
u/neotecha Jan 26 '22
That's... just wow...
I don't know why this bothers me as much as it does, but I did find
len((raw[0]))hidden in there.If you want to save the extra three characters to alias
rangetor_, why userangeagain in line 57?This is the code with some improved formatting:
66
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 26 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
26
u/UltraPoci Jan 26 '22
why
26
u/machine3lf Jan 26 '22
Is this minified in some way?
I would definitely vote for rewriting these functions from scratch, in a more sane way.
18
u/simonides_ Jan 26 '22
this is definitely the work of some processing either minified or obfuscated
14
u/Lich_Hegemon Jan 26 '22
To the best of my ability:
Not that it makes it any clearer, I have no idea what the goal is here
8
u/-MazeMaker- Jan 26 '22
I love that they use the "don't care" variable name
_in their for loop, then use the variable several times in that loop.6
u/30p87 Jan 27 '22
I would suggest CTRL+A Backspace
2
u/[deleted] Jan 27 '22
"look what I can do in just one line of code"
2
u/realGharren Jan 27 '22
Haskell coders: I see nothing wrong here.
1
u/Legendary-69420 Jan 27 '22
I got so angry after seeing this code. I literally felt like punching my laptop screen.
1
u/Erledigaeth Jan 27 '22
that should be illegal
1
u/hellra1zer666 Feb 08 '22
Unfortunately, I have colleagues who like to code like this. Whenever I have to debug their stuff, I have to rewrite their code first, so that you can actually debug it.
-6
u/tcbenkhard Jan 27 '22
Aah Python, the language that makes code look like cyphertext.