Alternativen zu online Rechtschreibkorrektur

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Alternativen zu online Rechtschreibkorrektur

Re: Alternativen zu online Rechtschreibkorrektur

by effel » 24 Jul 2023, 19:26

nachtrag, so geht es auch

Code: Select all

url := "https://www.google.com/search?q=super+truper+von+der+grubbe+appa+eine+musik+gruppe+der+80er"
anow := a_now
urlDownLoadToFile,% url,% a_scriptDir "\" anow " tmp.txt.html" 
fileRead, thisHTML,% a_scriptDir "\" anow " tmp.txt.html"
fileDelete,% a_scriptDir "\" anow " tmp.txt.html"
Doc := DocumentFromHTML(thisHTML)
res := doc.getElementsByName("scl")
MsgBox,,% a_lineNumber,% clipboard := res[0].innerText  
	; super trouper von der gruppe abba eine musikgruppe der 80er 
exitapp

Re: Alternativen zu online Rechtschreibkorrektur

by effel » 26 Jun 2023, 08:49

Hallo Just Me,

vielen Dank. Ich habe URLDownloadToVar(url) getestet, musste aber feststellen das es in meinem Fall nicht funktioniert, schon bei der ersten Abfrage bekomme ich eine Fehlermeldung.

Es läuft aber auch ohne ganz toll


06_26_23 @3_40_40.PNG
06_26_23 @3_40_40.PNG (11.02 KiB) Viewed 876 times

Code: Select all

	  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"
;         correction := "dies ist ein fehlerfreier text, er wird im original zurück gegeben"
	  
	  
	  split := strSplit(function(correction),"`n","`r")
          MsgBox % (split.1) ? (split.1 "`n`n" split.2 " mSec") : ""
	  exitapp


;#############
        function(correction) {
	url := "https://www.google.com/search?q=" (EncodeDecodeURI(correction,true, false)) "&ie=UTF-8"

	toVar := true        ; true erzeugt fehler 403
	if toVar
	{
	html := URLDownloadToVar(url)
	}else{
	  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 	(Result := EncodeDecodeURI(res,false, false)) 
				? Result "`n" (a_tickCount-StartTime)        ; return korriguert
				: (error#403 := FEHLER(html))
				? error#403 "`n" (a_tickCount-StartTime)     ; return error
				: correction "`n" (a_tickCount-StartTime)    ; return original
          }


;#############
FEHLER(html) {
	  loop, parse,% html, `n, `r
          if inStr(a_loopField,"Your client does not have permission to get URL") 
          res := xStr(a_loopField,,"<title>","</title>")
	  if res contains Error 403
	{
	  filedelete, Error#403.html
	  fileappend,% html, Error#403.html
	  try run, Error#403.html
	  return res
 }}

;#############
URLDownloadToVar(url){
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	return hObject.ResponseText
}

;#############
;- 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)
}

Re: Alternativen zu online Rechtschreibkorrektur

by just me » 23 Jun 2023, 07:03

Moin,

was immer es bringen mag, in der Doku zu UrlDownloadToFile findest Du ein Beispiel, wie man das auch ohne den Umweg über eine Datei machen kann. maestrith hat hier: viewtopic.php?t=3291 eine eigene Version als Funktion eingestellt.

Generell ist noch anzumerken, dass Dinge wie

Code: Select all

	  return 	(EncodeDecodeURI(res,false, false)) 
				? (EncodeDecodeURI(res,false, false)) "`n" (a_tickCount-StartTime)
				: correction "`n" (a_tickCount-StartTime)
grundsätzlich vermieden werden sollten. Du rufst hier für den Fall, dass der erste Funktionsaufruf ein korrektes Ergebnis liefern würde, die Funktion ein zweites Mal auf. Mit den AHK-eigenen Möglichkeiten ist Folgendes besser:

Code: Select all

	  return 	(Result := EncodeDecodeURI(res,false, false)) 
				? Result "`n" (a_tickCount-StartTime)
				: correction "`n" (a_tickCount-StartTime)
Beides Änderungen werden aber wahrscheinlich nicht viel bringen.

Deutlich schneller sollte eine Offline-Korrektur sein. Ich kenne aber keine entsprechenden Anwendungen.

Alternativen zu online Rechtschreibkorrektur

by effel » 23 Jun 2023, 05:12

Hallo,
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&amp;q=","&amp;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)
}
06_23_23 @11_47_15.PNG
06_23_23 @11_47_15.PNG (23.65 KiB) Viewed 963 times

Top