Git Product home page Git Product logo

profanity-filter's Introduction

PHP Profanity Filter

Simple PHP library designed to check a string against a pre-defined profanity list and return any matches

Installation

The prefered way to run this is via composer:

# composer require i-lateral/profanity-filter

Usage

The simplest way to use this library is eiwth to run a check, or get matched tags. Both of these methods execure this library and return results (but slightly differently).

This library also has some limited support for text within.

Check for profanity

The check function checks the submitted string against the profanity list and returns true if any matches were found.

use ilateral\ProfanityFilter\ProfanityFilter;

$string = "String to check";
$test = new ProfanityFilter($string);
$result = $test->check();

List all matched words

If you want more granular results than provided by the check function, you can instead use the get_matches method.

This method performs the same test, but returns an array of any matched words.

use ilateral\ProfanityFilter\ProfanityFilter;

$string = "String to check";
$test = new ProfanityFilter($string);
$result = $test->get_matches();

Adding or removing words to check

This library comes bundled with a pretty comprehensive list of words. But if you want to add more (ore remove some), you can use the methods provided.

Adding a word

To add a word to the profanity list, simply call the add_profanity method:

use ilateral\ProfanityFilter\ProfanityFilter;

$string = "String with custom word";
$test = new ProfanityFilter($string);
$test->add_profanity("custom");
$result = $test->check();

Removing a word

To remove a word to the profanity list, simply call the remove_profanity method:

use ilateral\ProfanityFilter\ProfanityFilter;

$string = "I like big butts and I cannot lie";
$test = new ProfanityFilter($string);
$test->remove_profanity("butts");
$result = $test->check();

profanity-filter's People

Contributors

mlewis-everley avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.