Search code examples
javascriptpythonnode.jsmodulenlp-question-answering

Detect if a question matches another question with python or js?


I'm trying to find out how I can detect if one question matches another with python or JS. For example detect that the question:

"Does anyone know the MySql password?"

is related to the question

"Does anyone know the MySql password?"

in order to give an automatic answer while limiting the number of false positives.


Solution

  • `

    let str1="Does anyone know the MySql password?"; 
    let str2="Does anyone know the MySql password?";
    
    let parsedStr1=str1.toLowerCase().replace(/\s/g,''); 
    let parsedStr2=str1.toLowerCase().replace(/\s/g,'');
    
    parsedStr1.localeCompare(parsedStr2);
    
    /* Expected Returns:
    
     0:  exact match
    
    -1:  string_a < string_b
    
     1:  string_a > string_b
    
    */
    

    `