Guest User

Untitled

a guest
Jun 13th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (def bad-word-lists ["english" "dutch" "french"])
  2.  
  3. (defn load-bad-word-list [name]
  4.   (read-lines (io/resource (str "badwords/" name ".txt"))))
  5.  
  6. (def bad-words (apply concat (map load-bad-word-list bad-word-lists)))
  7. (def bad-words-re (re-pattern (string/join "|" bad-words)))
  8.  
  9. (defn sanitize [text]
  10.   (println text bad-words-re)
  11.   (string/replace
  12.     text bad-words-re
  13.     (fn [badword]
  14.       (apply str (map (fn [[i l]]
  15.                         (if (= (mod i 3) 0)
  16.                           "-"
  17.                           l))
  18.                         (indexed badword))))))
Add Comment
Please, Sign In to add comment