Using Regex to score individual words in open-ended text | XM Community
Solved

Using Regex to score individual words in open-ended text

  • 1 February 2019
  • 1 reply
  • 8 views

Badge
I'd like to be able to give a question prompt and allow the respondent to provide sentences or even paragraphs of an answer, but score certain words with certain values attached. For example, if someone uses the word "global" in their answer, I'd like to give them two points. If they also use the phrase "open-minded" I'd like to give them three points. I don't want to give any points for words like "the", "and", etc. Does anyone know how to do this? Currently, the only way I can score words is to have a single-word answer and it must match the "right answer" exactly to get credit.
icon

Best answer by TomG 2 February 2019, 00:44

View original

1 reply

Userlevel 7
Badge +27
You can do this with JavaScript or a web service. Basically, you'll parse the paragraph into an array of individual words, then loop through the words and add up a score. You'll then set an embedded variable to equal the score.

Leave a Reply