Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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))))
Add Comment
Please, Sign In to add comment