diff --git a/src/ENCODER/BP/AnalyzeTextProcess.cls b/src/ENCODER/BP/AnalyzeTextProcess.cls index edbdb43..5fbaf5b 100644 --- a/src/ENCODER/BP/AnalyzeTextProcess.cls +++ b/src/ENCODER/BP/AnalyzeTextProcess.cls @@ -31,11 +31,11 @@ Method AnalyzeText(text As %String, analysisId As %String, language As %String) sqlsentence = "" # iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", "Starting process") for phraseToAnalyze in phrases : - iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", phraseToAnalyze) if phraseToAnalyze != "": embedding = model.encode(phraseToAnalyze, normalize_embeddings=True).tolist() sqlsentence = "INSERT INTO ENCODER_Object.TextMatches (CodeId, Description, Similarity, AnalysisId, RawText) SELECT TOP 50 * FROM (SELECT CodeId, Description, VECTOR_DOT_PRODUCT(VectorDescription, TO_VECTOR('"+str(embedding)+"', DECIMAL)) AS Similarity, '"+analysisId+"', '"+phraseToAnalyze+"' FROM ENCODER_Object.Codes) ORDER BY Similarity DESC" - iris.cls("ENCODER.Utils.Manager").ExecuteInsertQuery(sqlsentence) + stmt = iris.sql.prepare("INSERT INTO ENCODER_Object.TextMatches (CodeId, Description, Similarity, AnalysisId, RawText) SELECT TOP 50 * FROM (SELECT CodeId, Description, VECTOR_DOT_PRODUCT(VectorDescription, TO_VECTOR(?, DECIMAL)) AS Similarity, ?, ? FROM ENCODER_Object.Codes) ORDER BY Similarity DESC") + rs = stmt.execute(str(embedding), analysisId, phraseToAnalyze) except Exception as err: iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", repr(err)) return repr(err) diff --git a/src/ENCODER/Object/TextMatches.cls b/src/ENCODER/Object/TextMatches.cls index d321810..d6f2106 100644 --- a/src/ENCODER/Object/TextMatches.cls +++ b/src/ENCODER/Object/TextMatches.cls @@ -1,7 +1,7 @@ Class ENCODER.Object.TextMatches Extends (%Persistent, %JSON.Adaptor) { -Property RawText As %String; +Property RawText As %String(MAXLEN = 256); Property CodeId As %String; diff --git a/src/ENCODER/Utils/Manager.cls b/src/ENCODER/Utils/Manager.cls index 1d17fac..ad4d7b6 100644 --- a/src/ENCODER/Utils/Manager.cls +++ b/src/ENCODER/Utils/Manager.cls @@ -1,25 +1,6 @@ Class ENCODER.Utils.Manager Extends %RegisteredObject { -/// Description -ClassMethod ExecuteInsertQuery(sqlQuery As %String) As %String -{ - Try { - set statement = ##class(%SQL.Statement).%New() - set status = statement.%Prepare(sqlQuery) - if ($$$ISOK(status)) { - set result = statement.%Execute() - return result.%SQLCODE - } - else { - return "0" - } - } - Catch (ex) { - return "0" - } -} - ClassMethod GetEncoding(sentence As %String) As %String [ Language = python ] { import sentence_transformers