Skip to content

Instantly share code, notes, and snippets.

@seafoox
Created June 25, 2015 14:23
Show Gist options
  • Save seafoox/c04da8affe116d492021 to your computer and use it in GitHub Desktop.
Save seafoox/c04da8affe116d492021 to your computer and use it in GitHub Desktop.
Remove StopWords
var stopwordsList = ['l','le','la','les','du','de','des','a','du','en','au','aux','dont','par','pour','vos','es','est','sois','soit','sommes','sont','soyez','soyons','suis','étions','eté','êtes','ai','aie','aient','aies','ait','as','aura','aurai','auraient','aurais','aurait','auras','aurez','auriez','aurions','aurons','auront','avaient','avais','avait','avez','aviez','avions','avoirs','avons','ayant','ayez','ayons','eu','eue','eues','eurent','eus','ont'];
function removeStopWords(string) {
var queryWords = string.split(' ');
var finalString = [];
for (var i=0; i<queryWords.length-1; ++i) {
if (stopwordsList.indexOf(queryWords[i]) !== -1)
continue;
finalString.push(queryWords[i]);
}
finalString.push(queryWords[queryWords.length-1]);
return finalString.join(' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment