Guest User

Untitled

a guest
Dec 11th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. (ns bankocr.core)
  2.  
  3. (def parse {\space :., \_ :_, \| :|})
  4.  
  5. (defn parse-input [input] (map parse input ))
  6.  
  7. (def digits { [[:. :_ :.]
  8. [:| :. :|]
  9. [:| :_ :|]] 0
  10. [[:. :. :.]
  11. [:. :. :|]
  12. [:. :. :|]] 1
  13. [[:. :_ :.]
  14. [:. :_ :|]
  15. [:| :_ :.]] 2
  16. [[:. :_ :.]
  17. [:. :_ :|]
  18. [:. :_ :|]] 3
  19. [[:. :. :.]
  20. [:| :_ :|]
  21. [:. :. :|]] 4
  22. [[:. :_ :.]
  23. [:| :_ :.]
  24. [:. :_ :|]] 5
  25. [[:. :_ :.]
  26. [:| :_ :.]
  27. [:| :_ :|]] 6
  28. [[:. :_ :.]
  29. [:. :. :|]
  30. [:. :. :|]] 7
  31. [[:. :_ :.]
  32. [:| :_ :|]
  33. [:| :_ :|]] 8
  34. [[:. :_ :.]
  35. [:| :_ :|]
  36. [:. :_ :|]] 9})
  37.  
  38. (def lines [" _ _ _ _ _ _ _ _ "
  39. "| | | _| _||_||_ |_ ||_||_|"
  40. "|_| ||_ _| | _||_| ||_| _|"] )
  41.  
  42. (defn partitioin-digits [lines]
  43. (map #(partition 3 %) (map parse-input lines)))
  44.  
  45. (defn split-digits [digits]
  46. (map vector (first digits) (second digits) (nth digits 2)))
  47.  
  48. (defn ocr [lines]
  49. (map digits (split-digits (partitioin-digits lines))))
Add Comment
Please, Sign In to add comment