Profanity Filter
So the biggest advice I've gotten to learn programing is to just make stuff. So I thought I'd take what I saw from my latest lesson and try and apply it into something familair. I was learning boolean expressions and how the example showed a string and how it detected if the term 'fox' was present. I thought, 'Ok I can see how that comes in handy, it's probably how websites and stuff find and filter out profanity. So I decided to make one one but every time I run it, it comes back not detecting any.
Is this because I have the user input the string? Or is there something I'm missing.
Also this should go without saying but the code contains a number of dirty words so it'll be blurred for those who don't want to see it.

19 Replies

This creates a single string:
"bitchfuckshitcuntdamncockpussyassdickdyke"
I don't think the message you enter contains such a stringdont take my word for it but isnt the answer as simple as putting it as ("slur1") ("slur2") etc etc?
As in,
message.Contains("a")("b")("c")
? Nookay so ive been looking at it and the way i originally thought is calling it like literal functions
he would have to include after each slur
so
message.Contains("a")
message.Contains("b") ||
essentially saying instead of all these words it has this or this or this if that makes sense?
||text||
in Markdown is a spoiler, that's why we use code blocks with backticksits just a thought idk if it would work in practicallity
Bue yes, you're right
It would work, although I pity anybody who would have to write it for 100+ words
yeah lol, surely there is an easier way around it but if its only for a basic filter it should be fine as above
An array of words + a loop, or an array of words + LINQ
i hadnt even thought of an array tbf, though im still fairly new so im proud of myself for even managing to somewhat solve this problem lmao
What's LINQ?
Kind of like list comprehension in Python
There are more methods to it, of course. Like
.Any()
, .Contains()
, etc.Hm, well I'll learn that eventually. Right now the solution presented works just fine. Though now I feel bad for anyone whose worked on a game chat to have to go in and think up every single type of profanity.
Sure, everything in due time
Also, ready-made lists of profanities already exist for anyone to use
For example https://github.com/dsojevic/profanity-list
Or https://dedolist.com/lists/language/profane-words-english/api/
That's another thing I gotta learn, navigating github
you and me both, i have an account but i always forget to use it
i keep forgetting just how resourceful/powerful it is lol
Next problem, have a profanity filter, but not block Scunthorpe, and other false positives
Yeah I haven't gotten that far in learning yet XD