Zend Framework Badword filtering with Cdyne

One of my recent PHP projects had the requirement to filter out inappropriate language from user submitted content. After thinking about the problem briefly, I decided that I didn’t want to be writing the filter myself but, rather, find a third party service that could filter my text for me. By doing this, I eliminated the need to create and maintain a bad-word list, as well as saved the CPU cycles required to actually preform the search-and-replacement (Although, arguably, remote API calls are more expensive anyways).

After some searching I stumbled across the free Cdyne Profanity Filter Service. Not only does this service filter out the standard inappropriate language that you would expect, it also doesn’t produce false negatives (eg: the hello isn’t filtered for containing the word hell), and it has fairly robust phonetic character matching to catch things like a$$. The Cdyne service is exposed as a Soap WSDL so easy interfaces to languages other than PHP are possible.

I ended up writing a Zend Framework based Soap Client Service for the Cdyne filter, and I figured I would share it with any others who are looking to do filtering. In the following zip, there is the Service class, along with some unit tests demonstrating the use of the class methods. You should be able to rename the Zext_Service_Cdyne_ProfanityFilter class to one of your choosing if you do not like the pseudo namespacing I’ve used. Check out Cdyne’s wiki for more info.


, , ,

  1. #1 by Dave on September 6, 2012 - 8:18 pm

    I have just tried this out and it appears that the service does not work any more. I get:

    SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://ws.cdyne.com/ProfanityWS/Profanity.asmx?WSDL’ : Premature end of data in tag html line 3

  2. #2 by Matthew on February 14, 2013 - 12:27 pm

    @Dave , the new/accurate WSDL is http://wsf.cdyne.com/ProfanityWS/Profanity.asmx?WSDL , though it will currently return an error similar to ” A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) “. I’ve submitted a request with CDYNE about the issue, and will try to update this thread when I hear back.

(will not be published)