0

I'm hoping to get some help with the last piece of my extension. I've been working on a JS code that searches a dictionary based on user input from a text area and returns a match. That match is then assigned a series of values which are then put into the slider to control the mouth shapes. Am I on the right track here? I can get the input into separate words but I'm a little lost as to how to iterate through each word to check it against the dictionary.

document.getElementById("myButton").onclick = function(){
    var data = document.getElementById("myText").value;
    console.log(data);

    var strText = JSON.stringify(data);
    console.log(strText);

    string_to_array = function(str) {
        return str.trim().split(" ")
    }
    console.log(string_to_array(strText));

    console.log(strText);
}

localStorage.setItem("userInput", strText);

console.log(localStorage);

var fs = require("fs");

let text = fs.readFileSync("C:/Program Files (x86)/Common Files/Adobe/CEP/extensions/MULTIBUTTON/assets/standard_dictionary.txt").toString();
let index = text.match(strText)
let index = text.match(/(?:^|\W)doctor(?:$|\W)/gi);
console.log(index);
  • Can you also post a sample of what the word list looks like? If you could change your code sample to be a runnable snippet that would make it much easier for people to help you – Chris Barr Jul 20 '23 at 14:12
  • @ChrisBarr sure dude it's a giant list of words: ABBREVIATE AH0 B R IY1 V IY0 EY2 T ABBREVIATED AH0 B R IY1 V IY0 EY2 T AH0 D ABBREVIATES AH0 B R IY1 V IY0 EY2 T S ABBREVIATING AH0 B R IY1 V IY0 EY2 T IH0 NG ABBREVIATION AH0 B R IY2 V IY0 EY1 SH AH0 N ABBREVIATIONS AH0 B R IY2 V IY0 EY1 SH AH0 N Z ABBRUZZESE AA0 B R UW0 T S EY1 Z IY0 ABBS AE1 B Z – Urbanus1234 Jul 20 '23 at 14:30
  • Please edit your question and put the sample data in your code as a variable. You want to make is **EASY** for someone to help you. Currently they will have to copy/paste text from your comment and pate it into the code and edit out the node/file system stuff just to test it out. Please make a **working** code example in your question – Chris Barr Jul 20 '23 at 15:36
  • why are you stringify a string? Why is the code that uses `strText` not inside the click function? `match` expects a regular expression, you are giving it a string. – epascarello Jul 20 '23 at 17:14

0 Answers0