Skip to content
Snippets Groups Projects
Commit 178e137f authored by Stefan Plociennik's avatar Stefan Plociennik
Browse files

implemented profanity filter for german, english and french

parent 33d5ef31
No related merge requests found
import { Injectable } from '@angular/core';
import * as BadWordsList from 'badwords-list/lib/index.js';
import * as BadWords from 'naughty-words';
@Injectable({
providedIn: 'root'
})
export class TopicCloudAdminService {
private badWords: string[] = [];
private badWords = [];
get getBadWordList(): string[]{
return this.badWords;
}
constructor() {
this.badWords = BadWordsList.array;
this.badWords = BadWords;
}
filterProfanityWords(str: string): string{
let questionWithProfinity = str;
this.badWords.map(word =>{
questionWithProfinity = questionWithProfinity.toLowerCase().includes(word) ?
this.replaceString(questionWithProfinity.toLowerCase(), word, this.generateXWord(word.length))
: questionWithProfinity;
});
return questionWithProfinity;
// German Profanity
this.badWords['de'].map(word =>{
questionWithProfinity = questionWithProfinity.toLowerCase().includes(word) ?
this.replaceString(questionWithProfinity.toLowerCase(), word, this.generateXWord(word.length))
: questionWithProfinity;
});
// English Profanity
this.badWords['en'].map(word =>{
questionWithProfinity = questionWithProfinity.toLowerCase().includes(word) ?
this.replaceString(questionWithProfinity.toLowerCase(), word, this.generateXWord(word.length))
: questionWithProfinity;
});
// French Profanity
this.badWords['fr'].map(word =>{
questionWithProfinity = questionWithProfinity.toLowerCase().includes(word) ?
this.replaceString(questionWithProfinity.toLowerCase(), word, this.generateXWord(word.length))
: questionWithProfinity;
});
return questionWithProfinity;
}
addToBadwordList(word: string){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment