1

Been googling this for a bit, but i dont think i know how to phrase my question:

I have a client-side javascript app with an array of questions.

var questions = [
    'How are you?',
    'Where are you?',
    'How far away is the sun?'
];

I would like to compare a new question against the array of existing questions:

var newQuestion = "How are you doing today?";

Is there an existing client-side javascript library that will copmare the new question to the array of existing questions and return a result like:

[
    {
        original: "How are you?",
        similarity: .80
    },
    {
        original: "Where are you?",
        similarity: .71
    },
    {
        original: "How far away is the sun?",
        similarity: .13
    }
]

Any advice would be helpful!

simonwjackson
  • 1,818
  • 4
  • 25
  • 33

1 Answers1

0

Thanks to koopajah:

String_Score seems to get the job done

koopajah: What about this library : github.com/joshaven/string_score found in stackoverflow.com/questions/5859561/

Community
  • 1
  • 1
simonwjackson
  • 1,818
  • 4
  • 25
  • 33