mit folgendem Code überprüfe ich mit der Google Rechtschreibkorrektur einen Text, den ich mit Screen OCR eingelesen habe. Quasi als letzten Schliff in der Qualitätsprüfung.
Der Code funktioniert einwandfrei. Hat jemand Ideen für eine andere, vielleicht schnellere Herangehensweise?
Code: Select all
; https://www.google.com/search?q=in%20m%C3%BCnster%20und%20k%C3%B6ln%20sind%20die%20strasen%20saubber&ie=UTF-8
global startTime := a_tickCount
FileEncoding, UTF-8
correction := "in münster und köln sind die strasen saubber"
correction := "wievieele Tankstelen gibtt es in münster und köln"
split := strSplit(function(correction),"`n","`r")
MsgBox % split.1 "`n`n" split.2 " mSec"
exitapp
function(correction) {
url := "https://www.google.com/search?q=" (EncodeDecodeURI(correction,true, false)) "&ie=UTF-8"
urlDownloadToFile,% url, tmp_html.html
fileRead, html, tmp_html.html
FileDelete, tmp_html.html
res=
loop, parse,% html, `n, `r
if inStr(a_loopField,">Ergebnisse f")
res := xStr(a_loopField,,"href=""/search?ie=UTF-8&q=","&spell=1")
res := strReplace(res,"+",a_space)
return (EncodeDecodeURI(res,false, false))
? (EncodeDecodeURI(res,false, false)) "`n" (a_tickCount-StartTime)
: correction "`n" (a_tickCount-StartTime)
}
;- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=74050
xStr(ByRef H, C:=0, B:="", E:="",ByRef BO:=1, EO:="", BI:=1, EI:=1, BT:="", ET:="") {
Local L, LB, LE, P1, P2, Q, N:="", F:=0 ; xStr v0.97 by SKAN on D1AL/D343 @ tiny.cc/xstr
Return SubStr(H,!(ErrorLevel:=!((P1:=(L:=StrLen(H))?(LB:=StrLen(B))?(F:=InStr(H,B,C&1,BO,BI))?F+(BT=N?LB
:BT):0:(Q:=(BO=1&&BT>0?BT+1:BO>0?BO:L+BO))>1?Q:1:0)&&(P2:=P1?(LE:=StrLen(E))?(F:=InStr(H,E,C>>1,EO=N?(F
?F+LB:P1):EO,EI))?F+LE-(ET=N?LE:ET):0:EO=N?(ET>0?L-ET+1:L+1):P1+EO:0)>=P1))?P1:L+1,(BO:=Min(P2,L+1))-P1)
}
EncodeDecodeURI(str, encode := true, component := true) { ; autor unbekannt
static Doc, JS
if !Doc {
Doc := ComObjCreate("htmlfile")
Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
JS := Doc.parentWindow
( Doc.documentMode < 9 && JS.execScript() )
}
Return JS[ (encode ? "en" : "de") . "codeURI" . (component ? "Component" : "") ](str)
}