From 35760617a5f1e7f3cacbf9413e085b013329d0d6 Mon Sep 17 00:00:00 2001 From: Harry Yu Date: Thu, 24 Oct 2024 22:54:13 -0400 Subject: [PATCH] Updated the input clean up (issue #595) --- src/background/analysis/interactDB/ml/jsrun.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/background/analysis/interactDB/ml/jsrun.js b/src/background/analysis/interactDB/ml/jsrun.js index ad86cfcb..2899b5ff 100644 --- a/src/background/analysis/interactDB/ml/jsrun.js +++ b/src/background/analysis/interactDB/ml/jsrun.js @@ -46,6 +46,10 @@ export async function loadModel() { * @returns {Promise} boolean */ export async function useModel(input, test_model) { + // Replace multiple backslashes followed by a double quote with + // a single escaped backslash and double quote to normalize the input + const input_cleaned = input.replace(/\\+\"/g, '\\"'); + if (test_model != undefined) { model = test_model; } @@ -55,7 +59,7 @@ export async function useModel(input, test_model) { if (!tokenizer) { tokenizer = new BertTokenizer(true); } - var tokens = await tokenizer.tokenize(input); + var tokens = await tokenizer.tokenize(input_cleaned); const tLen = tokens.length; var attArr = []; if (tLen < 384) {