Skip to content

@thearthur /bankocr.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
clojure Dojo team 3
(ns bankocr.core)
(def parse {\space :., \_ :_, \| :|})
(defn parse-input [input] (map parse input ))
(def digits { [[:. :_ :.]
[:| :. :|]
[:| :_ :|]] 0
[[:. :. :.]
[:. :. :|]
[:. :. :|]] 1
[[:. :_ :.]
[:. :_ :|]
[:| :_ :.]] 2
[[:. :_ :.]
[:. :_ :|]
[:. :_ :|]] 3
[[:. :. :.]
[:| :_ :|]
[:. :. :|]] 4
[[:. :_ :.]
[:| :_ :.]
[:. :_ :|]] 5
[[:. :_ :.]
[:| :_ :.]
[:| :_ :|]] 6
[[:. :_ :.]
[:. :. :|]
[:. :. :|]] 7
[[:. :_ :.]
[:| :_ :|]
[:| :_ :|]] 8
[[:. :_ :.]
[:| :_ :|]
[:. :_ :|]] 9})
(def lines [" _ _ _ _ _ _ _ _ "
"| | | _| _||_||_ |_ ||_||_|"
"|_| ||_ _| | _||_| ||_| _|"] )
(defn partitioin-digits [lines]
(map #(partition 3 %) (map parse-input lines)))
(defn split-digits [digits]
(map vector (first digits) (second digits) (nth digits 2)))
(defn ocr [lines]
(map digits (split-digits (partitioin-digits lines))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.