-
-
Save jwcobb/5786037 to your computer and use it in GitHub Desktop.
/** | |
* Symbols that could be used to replace letters | |
* | |
* @var string | |
*/ | |
protected $_grawlix = '[!@#$%&*-]'; | |
/** | |
* Associative array of replacements to make | |
* | |
* @var array | |
* @lol http://www.youtube.com/watch?v=vbZhpf3sQxQ | |
*/ | |
protected $_replacements = array( | |
'/S' . $this->_grawlix . '{2}T/' => 'SHIT', | |
'/([Ss])' . $this->_grawlix . '{2}t/' => "$1" . 'hit', | |
'/P' . $this->_grawlix . '{2}s/' => 'PISS', | |
'/([Ss])' . $this->_grawlix . '{2}s/' => "$1" . 'iss', | |
'/F' . $this->_grawlix . '{2}K/' => 'FUCK', | |
'/([Ff])' . $this->_grawlix . '{2}k/' => "$1" . 'uck', | |
'/F' . $this->_grawlix . '{3}ING/' => 'FUCK', | |
'/([Ff])' . $this->_grawlix . '{3}ing/' => "$1" . 'ucking', | |
'/C' . $this->_grawlix . '{2}T/' => 'CUNT', | |
'/([Cc])' . $this->_grawlix . '{2}T/' => "$1" . 'unt', | |
'/C' . $this->_grawlix . '{2}K/' => 'COCK', | |
'/([Cc])' . $this->_grawlix . '{2}k/' => "$1" . 'ock', | |
'/P' . $this->_grawlix . '{4}Y/' => 'PUSSY', | |
'/([Pp])' . $this->_grawlix . '{4}y/' => "$1" . 'ussy', | |
); |
This seems to work pretty well
protected $_replacements = array(
'/([Ss])[hit!@#$%&*-]{3}/' => '$1hit',
'/S[HIT!@#$%&*-]{3}/' => 'SHIT',
'/([Pp])[usy!@#$%&*-]{4}/' => '$1ussy',
'/P[USY!@#$%&*-]{4}/' => 'PUSSY',
'/([Pp])[is!@#$%&*-]{3}/' => '$1iss',
'/P[IS!@#$%&*-]{3}/' => 'PISS',
'/([Mm])[otherfuck!@#$%&*-]{11}/' => '$1otherfucker',
'/F[OTHERFUCK!@#$%&*-]{11}/' => 'MOTHERFUCKER',
'/([Cc])[unt!@#$%&*-]{3}/' => '$1unt',
'/C[UNT!@#$%&*-]{3}/' => 'CUNT',
'/([Cc])[ock!@#$%&*-]{3}/' => '$1ock',
'/C[OCK!@#$%&*-]{3}/' => 'COCK',
'/([Dd])[amn!@#$%&*-]{3}/' => '$1amn',
'/D[AMN!@#$%&*-]{3}/' => 'DAMN',
'/([Aa])[s!@#$%&*-]{2}/' => '$1ss',
'/A[S!@#$%&*-]{2}/' => 'ASS',
'/([Bb])[itch!@#$%&*-]{4}/' => '$1amn',
'/B[ITCH!@#$%&*-]{4}/' => 'BITCH',
'/([Tt])[ity!@#$%&*-]{4}/' => '$1itty',
'/T[ITY!@#$%&*-]{4}/' => 'TITTY',
'/([Tt])[it!@#$%&*-]{2}(s)?/' => '$1it$2',
'/T[IT!@#$%&*-]{2}(S)?/' => 'TIT$1',
'/([Nn])[iger!@#$%&*-]{5}/' => '$1igger',
'/N[IGER!@#$%&*-]{5}/' => 'NIGGER',
'/([Nn])[iga!@#$%&*-]{4}(h)?/' => '$1igga$2',
'/N[IGA!@#$%&*-]{4}(H)?/' => 'NIGGA$1',
'/([Ff])[agot!@#$%&*-]{5}/' => '$1aggot',
'/F[AGOT!@#$%&*-]{5}/' => 'FAGGOT',
'/([Ff])[uck!@#$%&*-]{3}/' => '$1uck',
'/F[UCK!@#$%&*-]{3}/' => 'FUCK',
'/([Ff])[ag!@#$%&*-]{2}/' => '$1ag',
'/F[AG!@#$%&*-]{2}/' => 'FAG$1',
My issue with that is that you don't know the capitalization of the final product.
I just landed and don't have net access except for on my phone, but I can send you a little test I did on the flight.
Basically, my idea was that given a list of final band names, you pass a grawlixed string and it returns the one it thinks it is. It would convert all of "the f**_ing champs", "the ***_ing champs" and "the ******* champs" all properly.
It does it via conversion of the grawlixed string to a regex and comparing down the list. It's ruby, but its only like 30 lines of code.
https://gist.github.com/spikegrobstein/5813363
just remembered that I needed to post this. had limited free time on my trip to get on here.
Let me know what you think of this concept... basically I think you need a file that contains known degrawlixed strings since I have seen cases of censored band names being more ambiguous.
There are some limitations in my example which would need to be addressed in a final library. For one, I there would need to be hard-coded known censored names. For instance for "God Below" and "God Forbid" which are frequently grawlixed as "G- Forbid" or "G. Forbid" or "G-- Forbid". Maybe the degrawlix.db
file could be a slightly better format than just lists of final names, but rather have support for regex for special cases or specific hard-coded transformations. I'm just kinda spitballing here.
Also, I like your implementation of a grawlix character better than mine. I was thinking about the best way to do that on the plane, but I would have used yours had I had access on the plane, but was just trying to get it working.
I just don’t see this working out as I don't see a way to dynamically decide how many grawlixes may be present in a censored word.
For example, without specifying a lot of possibilities how can we make 'P---y', 'P--sy', 'Pu--y', 'P----' all end up as 'Pussy'?