Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Swear filter..  (Read 5548 times)
0 Members and 1 Guest are viewing this topic.
Offline Renoria

Junior Duke




...


« Posted 2009-04-27 07:44:08 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
public class GeneralChatHandler extends AbstractPacketHandler {
    public static String[] swearWords = {
        "f.*?u.*?k",
        "s.*?h.*?t",
        "bi.*?h",
        "bas.*?d",
        "m.*?f.*?",
        "c.*?nt",
        "as.*?s",
        "s.*?ck",
        "w.*?nk",
        "co.*?on",
        "wo.*?g",
        "ni.*?g.*?r",
        "c.*?c.*?k",
        "penis",
        "vagina",
        "c.*?um",
        "p.*?i.*?s",
        "p.*?orn",
        "ar.*?se",
        "nexon",
        "ho.*?r.*?ny",
        "dil.*?do",
        "doggystyle",
        "cl.*?it",
        "fann.*?y",
        "ho.*?re.*?",
        "kn.*?ob",
        "mastur.*?",
        "****",
        "hitler",
        "n.*?uts",
        "sob.*?",
        "shag.*?",
        "sl.*?ut.*?",
        "testi.*?",
        "t.*?wa.*?t",
        "viagr.*?a",
        "wil.*?ly",
        "wil.*?lie",
        "jism",
        "dog.*?gy",
        "donkeyri.*?b",
        "breas.*?t",
        "bl.*?wjo.*?b",
        "b.*?b",
        "beastiality",
        "an.*?al",
        "cawk",
        "pus.*?s.*?",
        "rim.*?m",
        "ejaculate",
        "ejakulate",
        "er.*?ct",
        "horni",
        "horna",
        "se.*?x",
        "se.*?ck",
        "ga.*?y",
        "fk",
        "we*?nis"
    };
   
    @Override public void handlePacket(SeekableLittleEndianAccessor slea, RenoriaClient c) {
        String text = slea.readRenoriaAsciiString();
        if (!CommandProcessor.executeCommand(c, c.getMessageCallback(), text.split(" "))) {
            c.getPlayer().getMap().broadcastMessage(PacketCreator.getChatBubble(c.getPlayer(), filter(text), c.getPlayer().isGM()));
        }
    }
   
    public static String filter(String in) {
        for (String swearWord : swearWords) {
            String stars;
            Pattern pat = Pattern.compile(swearWord, Pattern.CASE_INSENSITIVE);
            Matcher mat = pat.matcher(in);
            while (mat.find()) {
                char[] haha = new char[mat.end() - mat.start()];
                for (int i = 0; i < mat.end() - mat.start(); i++) {
                    haha[i] = '*';
                }
                stars = new String(haha);
                in = mat.replaceFirst(stars);
            }
        }
      return in;
   }
}


I'm using RegEXP to make the swear filter, but now I have 2 problems:

1) Ass is a swear word, but saying Assassin is blocked out too.

2) If I want to say "f**k", I can just say "fucl(".

any way around these problems?
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #1 - Posted 2009-04-27 07:56:52 »

Well, no, there's really no way around that.


In my opinion, don't do swear filters. It's not productive.
If someone wants to be offensive, they will be, either by using other words or by simply circumventing the filters.
It's possible to be VERY offensive without cursing at all, you know, and sometimes these stronger words are good for making a point.

If you HAVE to make a filter, make it just filter obvious the most offensive and obvious ones, like fu​ck. It'll make the users realize that you don't want them to swear and hopefully this will stop them. If they don't want to be stopped, you can't stop them.

Play Minecraft!
Offline zammbi

JGO Coder


Medals: 4



« Reply #2 - Posted 2009-04-27 08:25:31 »

Easy to break any swear filter. Just do the main words.
What I have added to our forums and soon the game is a word swap on swear word. Which makes the person looks silly/stupid, I don't know if this will reduce the swearing but its a interesting theory I'm looking into.
For example shit is slime, cock is rooster, f**k is fudge cake....

Current project - Rename and Sort
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #3 - Posted 2009-04-27 10:00:17 »

What I have added to our forums and soon the game is a word swap on swear word. Which makes the person looks silly/stupid, I don't know if this will reduce the swearing but its a interesting theory I'm looking into.
For example shit is slime, cock is rooster, f**k is fudge cake....

Never thounght about this solution... but I know some people that will swear only for the stupid result  Grin

Most of the time a swear filter is more annoying than usefull. People will still swear and the swear filter will filter sentence that should'nt be. If you want to put a system, do a (automatic ?) report system (far more works for GM/moderator though)
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2009-04-27 10:36:24 »

One nice trick is to filter swear words at the recipient's end, but not at the sender, and combine this with the idea of swapping out swear words for silly alternatives. That way I see that my message shows up as "You're all a  bunch of shits" but everyone else sees "You're all a bunch of kittens". Because the sender sees their message unchanged they don't bother trying to get around it with "sh!t" or similar.

Then your filter just becomes a simple exact word find and replace and you don't get problems with people from scunthorpe.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Ranger
« Reply #5 - Posted 2009-04-27 10:49:30 »

I just did the basic bad words on my site.  Seems to work well:
1  
2  
3  
4  
5  
6  
7  
8  
      pText = pText.replaceAll("(?i)clit","c***");
      pText = pText.replaceAll("(?i)cock","c**k");
      pText = pText.replaceAll("(?i)cunt","c**t");
      pText = pText.replaceAll("(?i)dick","d**k");
      pText = pText.replaceAll("(?i)f**k","f**k");
      pText = pText.replaceAll("(?i)prick","p***k");
      pText = pText.replaceAll("(?i)shit","s**t");
      pText = pText.replaceAll("(?i)slut","s***");


EDIT:  I see there is a swear filter on this site too for the F word which changes it exactly like I do.  Smiley
Offline zammbi

JGO Coder


Medals: 4



« Reply #6 - Posted 2009-04-27 11:02:53 »

I would do it both on the sending and receiving of the client.
Both to make it harder for people to view swear words and on the client to take the load off the server.

Quote
but I know some people that will swear only for the stupid result
Our forums have been fine, though we have warned people not to abuse it. But the real test when we add it in game which be soon hopefully.

It also has made the forums a friendlier place and less fighting when small insults are replaced like: noob to newbie, ass to bottom, crap to cream, etc.

I like to share a quote of a post(hidden in our bad post area) which has been filtered which I found really funny  Wink
Quote
man get a life u pathetic fool... s*ck my fudge cake rooster u fudge cake plateless hopless daisy you can eat my rooster meat sandiwch all day you little goose boy...


Current project - Rename and Sort
Offline Renoria

Junior Duke




...


« Reply #7 - Posted 2009-04-27 12:30:11 »

I would do it both on the sending and receiving of the client.
Both to make it harder for people to view swear words and on the client to take the load off the server.
Our forums have been fine, though we have warned people not to abuse it. But the real test when we add it in game which be soon hopefully.

It also has made the forums a friendlier place and less fighting when small insults are replaced like: noob to newbie, ass to bottom, crap to cream, etc.

I like to share a quote of a post(hidden in our bad post area) which has been filtered which I found really funny  Wink


awesome idea, now I just need a list of those words looooooooooooool
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #8 - Posted 2009-04-27 17:24:13 »

I would do it both on the sending and receiving of the client.
Both to make it harder for people to view swear words and on the client to take the load off the server.
Our forums have been fine, though we have warned people not to abuse it. But the real test when we add it in game which be soon hopefully.

It also has made the forums a friendlier place and less fighting when small insults are replaced like: noob to newbie, ass to bottom, crap to cream, etc.

I like to share a quote of a post(hidden in our bad post area) which has been filtered which I found really funny  Wink

Heh heh that's pretty awesome. Good work.

See my work:
OTC Software
Offline JoglHurt

Senior Newbie





« Reply #9 - Posted 2009-04-30 19:34:24 »

If I would like to censor "ass" but not "assassin" then my non-regex bubblegum solution would be to replace " ass " with something like " a** ". Pay attention to spaces. Assassin doesn't contain space after ass so it won't be touched.

Speak to me like you would speak to a vegetable and I may understand what you say.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #10 - Posted 2009-04-30 19:47:11 »

yeah for censoring whole words just use the space character " " at both ends.

Also one decent options is how youtube colapses spam.
So make it difficult on the clients end to access offencive material. This way the poster (who wants the attention) will be less likely to make there message viewed by less people.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Crucio

Senior Newbie





« Reply #11 - Posted 2009-04-30 20:45:55 »

One nice trick is to filter swear words at the recipient's end, but not at the sender, and combine this with the idea of swapping out swear words for silly alternatives. That way I see that my message shows up as "You're all a  bunch of shits" but everyone else sees "You're all a bunch of kittens". Because the sender sees their message unchanged they don't bother trying to get around it with "sh!t" or similar.

Then your filter just becomes a simple exact word find and replace and you don't get problems with people from scunthorpe.

I think this is a very good idea. A game I used to play called Infantry (or Cosmic Rift) had this implemented.

If you swore it would appear completely normal, such as "for f**ks sake", but every other recipient wouldn't receive this message.

It worked very well. It took most people a long time to realise that swear words wern't allowed, and even if you knew, it was easy to forget as the messages all appeared like normal on your side.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #12 - Posted 2009-04-30 21:17:11 »

If I would like to censor "ass" but not "assassin" then my non-regex bubblegum solution would be to replace " ass " with something like " a** ". Pay attention to spaces. Assassin doesn't contain space after ass so it won't be touched.
Then you could just write assassassassassf**kf**kf**kballsshitcrap etc.

See my work:
OTC Software
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 823
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2009-04-30 21:27:47 »

You can't beat creativity, think about misspellings.

It's all just about raising the bar, and filtering everybody except yourself (as described above) is a pretty nice high bar.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zammbi

JGO Coder


Medals: 4



« Reply #14 - Posted 2009-05-01 05:29:27 »

Well as I said, anyone can break a swear filter.
If you wanted a swear filter that targeted all swear words easily, then you would have 2 lists of words, one for the bad words and another list which has words like 'Assassin' and not filter those words out.
Therefore even if people try to "assassassassassf**kf**kf**kballsshitcrap" it would be filtered out.
You would have to do a lot of testing to make sure good words are not filtered out.

Current project - Rename and Sort
Offline markmistry

Junior Duke





« Reply #15 - Posted 2009-05-01 09:53:41 »

Just a thought what about foreign  swear words ?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 823
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #16 - Posted 2009-05-01 09:55:29 »

User generated 'content'.

--> a list of 'bad words' that is managed by your users.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #17 - Posted 2009-05-01 10:20:39 »

User generated 'content'.

--> a list of 'bad words' that is managed by your users.

someone could make "cheese" as swear word :/, word require some admin.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 823
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #18 - Posted 2009-05-01 10:31:15 »

That's why it's not 'added' by users, but 'managed' by users.


If the majority of users thinks 'cheese' is a bad word... so be it.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #19 - Posted 2009-05-01 11:52:51 »

hehe, cheese  Lips Sealed I gotta watch my language.
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #20 - Posted 2009-05-01 22:49:46 »

I used a different approach for my swear filter. Instead of replacing swear words, I ban a user from the chat for 7 minutes! It makes people a lot more careful what they type...

Offline zammbi

JGO Coder


Medals: 4



« Reply #21 - Posted 2009-05-02 04:45:33 »

Quote
I used a different approach for my swear filter. Instead of replacing swear words, I ban a user from the chat for 7 minutes! It makes people a lot more careful what they type...

Well that would have to be server controlled. But maybe that could be smart thing to do, have a small list of the common worse words, so the server doesn't have to do a lot of checking. Then have the client filter the rest of the words.

Current project - Rename and Sort
Offline JoglHurt

Senior Newbie





« Reply #22 - Posted 2009-05-03 17:56:56 »

Then you could just write assassassassassf**kf**kf**kballsshitcrap etc.

Well nothing's perfect. It wouldn't also censor ass if it would be first or last word (assuming that no-one writes space in the beginning or the end of the sentence) what it would probably be in short comments. To get perfectly rid of swear words you must write artificial intelligence which compares to human IQ above about 70 on mensa scale. I think that would be pretty hard to accomplish.  Undecided

Speak to me like you would speak to a vegetable and I may understand what you say.
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #23 - Posted 2009-05-03 18:41:09 »

IQ above about 70 on mensa scale

lol, wut?

Play Minecraft!
Offline Mike

JGO Wizard


Medals: 86
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #24 - Posted 2009-05-03 20:34:01 »

lol, wut?

Yes, compared to over 70 on the richter scale.

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline DzzD
« Reply #25 - Posted 2009-05-03 21:28:06 »

what about adding "punition" in addition to the swear filter ?

like on a chat if someone use one or more badword he will have to wait (be kicked) one minute to send another post if he send another badword then he must wait 2min a third 4min, 8min, 16min etc...

and on a forum : 1h, 2h , 4h , 8h, etc...

without mentionning the sanctionned word, it will be fastly boring to try to hack such filter, no ?

EDIT :
I just see that was mentionned earlier, increasing the ban length can improve this a little

Quote
I used a different approach for my swear filter. Instead of replacing swear words, I ban a user from the chat for 7 minutes! It makes people a lot more careful what they type...

Offline JoglHurt

Senior Newbie





« Reply #26 - Posted 2009-05-04 07:25:50 »

lol, wut?

That was odd text from me.

Humm.. I could correct that text but I'll rather humiliate myself and won't do it.   Kiss

Speak to me like you would speak to a vegetable and I may understand what you say.
Offline Cero
« Reply #27 - Posted 2009-05-04 09:23:02 »

I agree with Markus_Persson

Because I for one, hate swear filters, its just childish

its asssssss

Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #28 - Posted 2009-05-04 11:18:26 »

That was odd text from me.

Humm.. I could correct that text but I'll rather humiliate myself and won't do it.   Kiss

Sorry, I didn't mean to ridicule. I just got thrown off by the mention of a mensa scale. =D

Play Minecraft!
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 823
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #29 - Posted 2009-05-04 17:29:17 »

mensa only 'rates' in percentile, in my experience.

lower threshold is 0.98, max is 1.00-(1/6.5B), are you can't be smarter than yourself.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (33 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (59 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!