Simple Profanity Filter

0

A simple Java program demonstrating the use of CDYNE's FREE Profanity Filter API . Note that the code just demonstrates the setting up of a simple profanity filter , the API includes much more functionalities . Check out the CDYNE Wiki for how to implement a profanity filter suited to your needs .



/** *PUBLIC SOFTWARE * *This source code has been placed in the public domain. You can use, modify, and distribute *the source code and executable programs based on the source code. * *However, note the following: * *DISCLAIMER OF WARRANTY * * This source code is provided "as is" and without warranties as to performance * or merchantability. The author and/or distributors of this source code may * have made statements about this source code. Any such statements do not constitute * warranties and shall not be relied on by the user in deciding whether to use * this source code.This source code is provided without any express or implied * warranties whatsoever. Because of the diversity of conditions and hardware * under which this source code may be used, no warranty of fitness for a * particular purpose is offered. The user is advised to test the source code * thoroughly before relying on it. The user must assume the entire risk of * using the source code. * */ import java.io.*; import java.net.*; /** * * @author amal * version 1.0 */ public class CDYNEFilterDemo { public static void main(String[] args) { BufferedReader in = null; try { String text = "test profanity bullshit"; URL url = new URL("http://ws.cdyne.com/ProfanityWS/Profanity.asmx/SimpleProfanityFilter?Text="+URLEncoder.encode(text,"UTF-8")); in = new BufferedReader(new InputStreamReader(url.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (null != in) { in.close(); } } catch (IOException e) { // ignore } } } }

Read more »

0 comments:

Post a Comment

© Zone817. Powered by Blogger.