diff --git a/encoder-ui/src/app/analyzer/analyzer.component.ts b/encoder-ui/src/app/analyzer/analyzer.component.ts index 748d655..e027c36 100644 --- a/encoder-ui/src/app/analyzer/analyzer.component.ts +++ b/encoder-ui/src/app/analyzer/analyzer.component.ts @@ -67,43 +67,61 @@ export class AnalyzerComponent { "Text": textToProcess[index], "Language": this.translocoService.getActiveLang() }; - this.irisService.analyzeText(textData).subscribe({next: res =>{ - if (res.length > 0){ - this.diagnostics = this.diagnostics.concat(res); - } + this.irisService.analyzeText(textData).subscribe({next: resp =>{ this.totalReceived += forReading; if (this.totalReceived >= 100){ - this.diagnostics.forEach((diagnostic, indexDiag) => { - let phrase = ""; - if (diagnostic.RawText.split(" ").length == 3){ - phrase = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[2],"ig"))[0]; + this.irisService.getAnalysisDetails(raw.id).subscribe({next: res => { + if (res.length > 0){ + this.diagnostics = this.diagnostics.concat(res); } - else if (diagnostic.RawText.split(" ").length == 2){ - phrase = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[1],"ig"))[0]; - } - else if (diagnostic.RawText.split(" ").length == 4){ - phrase = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[3],"ig"))[0]; - } - else if (diagnostic.RawText.split(" ").length == 1){ - phrase = textOriginal.match(diagnostic.RawText); - } - var indexDiag = this.textAndDiagnosticList.findIndex(obj => obj.rawText == phrase); - const diagnosticEncoded: Diagnostic = {code: diagnostic.CodeId, description: diagnostic.Description, similarity: diagnostic.Similarity} - if (indexDiag == -1) - { - textHTML = textHTML.replace(phrase,""+phrase+""); - let textAndDiagnostic: TextAndDiagnostic = {rawText: phrase, diagnostics: []}; - textAndDiagnostic.diagnostics.push(diagnosticEncoded); - this.textAndDiagnosticList.push(textAndDiagnostic); - } - else { - this.textAndDiagnosticList[indexDiag].diagnostics.push(diagnosticEncoded) - } - }) - this.textUpdated = textHTML - this.loading = false; - } - }, + this.diagnostics.forEach((diagnostic, indexDiag) => { + let phrase: string = ""; + if (diagnostic.RawText.split(" ").length == 3){ + const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[2],"ig")); + if (matchValue) { + phrase = matchValue[0]; + } + } + else if (diagnostic.RawText.split(" ").length == 2){ + const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[1],"ig")); + if (matchValue) { + phrase = matchValue[0]; + } + } + else if (diagnostic.RawText.split(" ").length == 4){ + const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[3],"ig")); + if (matchValue) { + phrase = matchValue[0]; + } + } + else if (diagnostic.RawText.split(" ").length == 1){ + const matchValue = textOriginal.match(diagnostic.RawText); + if (matchValue) { + phrase = matchValue[0]; + } + } + var indexDiag = this.textAndDiagnosticList.findIndex(obj => obj.rawText == phrase); + const diagnosticEncoded: Diagnostic = {code: diagnostic.CodeId, description: diagnostic.Description, similarity: diagnostic.Similarity} + if (indexDiag == -1) + { + textHTML = textHTML.replace(phrase,""+phrase+""); + let textAndDiagnostic: TextAndDiagnostic = {rawText: phrase, diagnostics: []}; + textAndDiagnostic.diagnostics.push(diagnosticEncoded); + this.textAndDiagnosticList.push(textAndDiagnostic); + } + else { + this.textAndDiagnosticList[indexDiag].diagnostics.push(diagnosticEncoded) + } + }) + this.textUpdated = textHTML + this.loading = false; + }, + error: err => { + this.error = true; + this.loading = false; + }}); + } + }, error: err => { this.error = true; this.loading = false; diff --git a/src/ENCODER/WS/Service.cls b/src/ENCODER/WS/Service.cls index 20ef584..9d004f1 100644 --- a/src/ENCODER/WS/Service.cls +++ b/src/ENCODER/WS/Service.cls @@ -156,24 +156,7 @@ ClassMethod AnalyzeText() As %Status // Creation of BS instance set status = ##class(Ens.Director).CreateBusinessService("ENCODER.BS.AnalyzeTextService", .instance) set tSC = instance.SendRequestSync("ENCODER.BP.AnalyzeTextProcess", analysisRequest, .response) - - set sql = - "SELECT CodeId, RawText, Description, max(Similarity) as Similarity FROM ENCODER_Object.TextMatches WHERE AnalysisId = ? GROUP BY CodeId ORDER BY Similarity DESC" - - set statement = ##class(%SQL.Statement).%New() - $$$ThrowOnError(statement.%Prepare(sql)) - set rs = statement.%Execute(response.AnalysisRequestId) - - set array = [] - while rs.%Next() { - do array.%Push({ - "CodeId": (rs.%Get("CodeId")), - "RawText": (rs.%Get("RawText")), - "Description": (rs.%Get("Description")), - "Similarity": (rs.%Get("Similarity")) - }) - } - write array.%ToJSON() + set %response.Status = ..#HTTP200OK } catch ex {