Skip to content

Commit b5107b9

Browse files
authored
Merge pull request #596 from privacy-tech-lab/595-create-new-release-v131
Updated the input clean up (issue #595)
2 parents 79bac7e + 3576061 commit b5107b9

File tree

1 file changed

+5
-1
lines changed
  • src/background/analysis/interactDB/ml

1 file changed

+5
-1
lines changed

src/background/analysis/interactDB/ml/jsrun.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export async function loadModel() {
4646
* @returns {Promise<boolean>} boolean
4747
*/
4848
export async function useModel(input, test_model) {
49+
// Replace multiple backslashes followed by a double quote with
50+
// a single escaped backslash and double quote to normalize the input
51+
const input_cleaned = input.replace(/\\+\"/g, '\\"');
52+
4953
if (test_model != undefined) {
5054
model = test_model;
5155
}
@@ -55,7 +59,7 @@ export async function useModel(input, test_model) {
5559
if (!tokenizer) {
5660
tokenizer = new BertTokenizer(true);
5761
}
58-
var tokens = await tokenizer.tokenize(input);
62+
var tokens = await tokenizer.tokenize(input_cleaned);
5963
const tLen = tokens.length;
6064
var attArr = [];
6165
if (tLen < 384) {

0 commit comments

Comments
 (0)