Code Monkey home page Code Monkey logo

Comments (3)

adambair avatar adambair commented on August 19, 2024

Agreed, this is an issue - I'll look at adding substring support soon.

from profanity_filter.

ealdent avatar ealdent commented on August 19, 2024

It's not hard to implement naively, it just means you go from having O(1) lookups on the dictionary hash to having O(d) (size of dictionary) lookups per word. By naive, I mean for each word in the input text, you check every word in the dictionary to see if the dictionary word is a substring of that word. So your total runtime goes from O(n) to O(nd).

The problem is your false positive rate will go through the roof, probably unacceptably so. For example, assemble would be caught by naive substring matching. Alternatively you can do something like

  • check if word is in dictionary (O(1))
  • if not, attempt to split into multiple words and check each one for profanity (O(2^m) where m is the length of the word if implemented naively.. can get it down to O(m^2) using memoization, maybe there are even better ways out there)

This would basically increase the runtime to O(nm^2) (where m would be the average length of a word). So maybe a factor of 25 worse than current?

from profanity_filter.

adambair avatar adambair commented on August 19, 2024

It was bound to happen. Damn you classical computer science! I'd have to look that stuff up if I wanted to know the specifics... I'll keep your comment in mind when I tackle this... unless someone beats me to it... ;)

from profanity_filter.

Related Issues (5)

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.