Skip to content

"Vanilla JavaScript" Filtering Profanity Using Levenshtein Distance Algorithm

License

Notifications You must be signed in to change notification settings

dwirifki10/Fuzzy-Filtering-Profanity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fuzzy Filtering Profanity

is a RestFull APIs for filtering profanity by using Levenshtein Distance algorithm. Built with Vanilla JavaScript and combined using Hapi Framework for making APIs. It allows you to build a website for blocking the harsh words.

How it works

  1. Put your sentences or paragraph.
  2. Your sentences or paragraph will split into an array.
  3. Do filtering on the same word.
  4. Do filtering on the exception data.
  5. Do Levenshtein Distance algorithm.
  6. Return the result of Levenshtein Distance algorithm.

Payload Status
merge Boolean default (false)
sentence String required
inclusion Array not required
exclusion Array not required
Method Path
POST https://project-app-forum.herokuapp.com/api/v1/filter?merge=true
{
    "status": "success",
    "data": {
        "result": {
            "merge": true,
            "free_profanity_score": 100,
            "words_count": 3,
            "found": 0,
            "warning": 0,
            "index_array": [],
            "index_arr_warning": [],
            "initial_sentence": "Levenshtein Distance Checker",
            "new_sentence": "Levenshtein Distance Checker"
        }
    }
}

How to change your sentence or paragraph into an array ?

const regex = /([.,!:;"'])/gi;

const result = sentence.replace(regex, "$1 ").split(" ").filter((item) => { if (item !== "") { return item } });

About

"Vanilla JavaScript" Filtering Profanity Using Levenshtein Distance Algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published