/# Azure Cognitive Service の Read API を実行する T2@ASAHI Accounting Robot 研究所#/ /#  環 境 設 定 ========================================#/ # エンドポイント SET Endpoint TO $'''https://{リソース}.cognitiveservices.azure.com/''' # サブスクリプションキー SET SubscriptionKey TO $'''サブスクリプションキー''' # バージョン(2021/11/22時点では v3.2 が最新) SET Version TO $'''v3.2''' /# モデルバージョン latest:最新のGA。推奨(2021/11/22時点では 2021-04-12 ) 2021-09-30-preview:プレビュー版。2021-04-12に比べ、精度がかなり高いため、こちらを設定#/ SET ModelVersion TO $'''2021-09-30-preview''' /# ======================================== #/ Display.SelectFileDialog.SelectFile Title: $'''テキストを抽出したいファイルを選択してください''' IsTopMost: True CheckIfFileExists: True SelectedFile=> SelectedFile Scripting.RunDOSCommand.RunDOSCommand DOSCommandOrApplication: $'''curl -i -X POST -H \"Content-Type:application/octet-stream\" -H \"Ocp-Apim-Subscription-Key:%SubscriptionKey%\" --data-binary \"@%SelectedFile%\" \"%Endpoint%vision/%Version%/read/analyze?model-version=%ModelVersion%\"''' StandardOutput=> CommandOutput Text.ParseText.RegexParseForFirstOccurrence Text: CommandOutput TextToFind: $'''Operation-Location:[\\s\\S]*?\\r\\n''' StartingPosition: 0 IgnoreCase: False Match=> Match Text.Replace Text: Match TextToFind: $'''(Operation-Location: |\\n|\\r)''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> RequestUrl LOOP LoopIndex FROM 1 TO 60 STEP 1 WAIT 1 Web.InvokeWebService.InvokeWebService Url: RequestUrl Method: Web.Method.Get Accept: $'''application/xml''' ContentType: $'''application/xml''' CustomHeaders: $'''Ocp-Apim-Subscription-Key:%SubscriptionKey%''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: True UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.6''' Encoding: Web.Encoding.AutoDetect AcceptUntrustedCertificates: False Response=> WebServiceResponse StatusCode=> StatusCode Variables.ConvertJsonToCustomObject Json: WebServiceResponse CustomObject=> Response IF Response.status <> $'''running''' THEN EXIT LOOP END END IF Response.status <> $'''succeeded''' THEN EXIT Code: 0 ErrorMessage: WebServiceResponse END Excel.LaunchExcel.Launch Visible: True LoadAddInsAndMacros: False Instance=> ExcelInstance SET RowNo TO 1 LOOP FOREACH Result IN Response.analyzeResult.readResults LOOP FOREACH Line IN Result.lines Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: Line.text Column: $'''A''' Row: RowNo SET RowNo TO RowNo + 1 END END