This is a proof-of-concept level software.
Stockade is a Personally Identifiable Information (PII) detector. It scans unstructured text (from files, logs, databases, web etc.) and masks all identified pieces of PII.
gem install stockade
require 'stockade'
puts Stockade.mask(<<-EOS
Dossier on Mr. John Smith born 09/02/1995
His email is jsmith@example.com and his phone is 555-123-4567.
He is using Visa card 4111 1111 1111 1111
EOS
#=>
Dossier on Mr. **** ***** born **********
His email is ****************** and his phone is ************.
** is using Visa card *******************
Notice, how word 'He' was incorrectly identified as a name.
This is done in three stages.
Using a manually curated list of regexes and StringScanner it extracts and labels lexeme candidates.
Lexeme candidates further evaluated (in some cases this is a no-op) to filter out false positives. For example, first and lastnames are checked against a database of known names. Dates are checked to be in the past.
Some rudimentary parsing done. Lexemes that are fully covered by other lexemes are eliminated. Ambiguous lexemes are disambiguated using rules of precedence.