From 1bd82876223795ba85206365ef53ba06227fa718 Mon Sep 17 00:00:00 2001 From: Daniel Berry Date: Sun, 23 Jul 2017 15:29:05 -0500 Subject: [PATCH] any word with a number in it gets a zero --- pronounceable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pronounceable.js b/pronounceable.js index 59ff648..717c101 100644 --- a/pronounceable.js +++ b/pronounceable.js @@ -17,7 +17,7 @@ var triples = JSON.parse( // Remove any non-alphabet characters // and convert to lower case. function clean(word) { - return word.replace(/[^a-zA-Z]/g, "").toLowerCase(); + return word.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(); } // Make a percentage. @@ -29,6 +29,8 @@ function percent(score, count) { function undef(w, i, depth, probs) { if (depth <= 1) return typeof probs[w[i]] === "undefined"; if (typeof probs[w[i]] === "undefined") return true; + var nums = '0123456789'; + if (nums.indexOf(w[i]) !== -1) return true; return undef(w, i + 1, depth - 1, probs[w[i]]); }