Added multi character splits to split by &, , and $

This commit is contained in:
Mark Beamer Jr 2018-11-12 21:33:18 -05:00
parent 9095016894
commit af4329b9e7
No known key found for this signature in database
GPG key ID: 1C314FB89AD76973

View file

@ -318,8 +318,10 @@ function getStatus () {
function getWashedQuery (query) {
// compress multiple white spaces to 1
query = query.toLowerCase().replace(/ +/g, ' ');
let splitBy = ['&', '$', ' '];
let regex = new RegExp(splitBy.join('|'), 'gi');
let badWords = [ 'from', 'with', 'not', 'can', 'all', 'are', 'for', 'but', 'and', 'the' ];
let words = query.split(' ');
let words = query.split(regex);
let sentence = [];
words.forEach(w => {
if (!badWords.includes(w)) { sentence.push(w) }