Skip to content

Instantly share code, notes, and snippets.

@rightisleft
Created September 24, 2019 20:36
Show Gist options
  • Save rightisleft/1d17f3cdec48168e3d32b2d7f2f9571c to your computer and use it in GitHub Desktop.
Save rightisleft/1d17f3cdec48168e3d32b2d7f2f9571c to your computer and use it in GitHub Desktop.
getDirtyStopwords(): boolean {
// a swl that is not in rswl
// a swl that is not in rswl AND not custom stopwords
const newUserGeneratedStopWordLiss: DTOStopWords[] = this.lens.stopWordLists.filter(swl => {
const rootMirror: DTOStopWordsRoot = this.lens.rootStopWords.find(rswl => rswl.uuid === swl.uuid);
return !rootMirror && swl.name !== 'Custom Stop Words';
});
if (newUserGeneratedStopWordLiss.length > 0) {
return true;
}
// a rswl that is missing from swl
const missingRoots: DTOStopWordsRoot[] = this.lens.rootStopWords.filter(rswl => {
const match: DTOStopWords = this.lens.stopWordLists.find(swl => swl.uuid === rswl.uuid);
return !match;
});
if (missingRoots.length > 0) {
return true;
}
// if changewords exists on any of the active stop words
const foundNewChangeWords: DTOStopWordsRoot = this.lens.stopWordLists.find(swl => {
if (!!swl && Object.keys(swl.changeWords).length > 0) {
return true;
}
});
if (!!foundNewChangeWords) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment