 ;     for i in range(1,len(s)+1):
 ;         c,k = best_match(i)
 ;         cost.append(c)
-(defn build-cost-array
+(defn- build-cost-array
   [s]
   (loop [i 1
          cost [0]]

;
;     return " ".join(reversed(out))
(defn infer-spaces
  [input]
  (let [s (s/lower-case input)
        cost (build-cost-array s)]


; # Build a cost dictionary, assuming Zipf's law and cost = -math.log(probability).
; words = open("words-by-frequency.txt").read().split()
(def ^:const ^:private words (s/split-lines (slurp (io/file (io/resource "words-by-frequency.txt")))))

; wordcost = dict((k, log((i+1)*log(len(words)))) for i,k in enumerate(words))
(def ^:const ^:private word-cost
  (apply hash-map (flatten (map-indexed
    (fn [idx word] [word (Math/log (* (+ idx 1) (Math/log (count words))))]) words))))

; maxword = max(len(x) for x in words)
(def ^:const ^:private max-word (apply max (map count words)))

; def infer_spaces(s):
;     """Uses dynamic programming to infer the location of spaces in a string
