We have a list of "severe" words which we want to match and obscure against incoming sentences.
e.g.
words = ['shoots', 'forest floor', 'leaves']
sentence = 'The panda eats, shoots, and leaves on the forest floor.'
obscure(words, sentence)
=> 'The panda eats, s*****, and l***** on the f********.'
The difficult bit is that some of the severe words are so severe that we store them in a hashed format. So our annotators may input shoots but it is stored as 92415d1bb58ff22c1a98cb610bf0d774. Then;
words = ['92415d1bb58ff22c1a98cb610bf0d774', 'forest floor', 'leaves']
sentence = 'The panda eats, shoots, and leaves on the forest floor.'
obscure(words, sentence)
=> 'The panda eats, s*****, and l***** on the f********.'
For single words (shoots) we can easily chop up the input sentence and match even the hashed words.
But multi-words (forest floor) is challenging. I have yet to figure out an elegant regex or iterative method for doing this.
Ideally we solve this in Python though JavaScript and Ruby are available to us if they have existing solutions or a large benefit.