Skip to content

Instantly share code, notes, and snippets.

@thearthur
Created August 29, 2012 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thearthur/3506760 to your computer and use it in GitHub Desktop.
Save thearthur/3506760 to your computer and use it in GitHub Desktop.
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