Skip to main content

No project description provided

Project description

aococr - Advent of Code ASCII-art character recognition

OCR tool in python for Advent of Code (AoC) ASCII art.

Som AoC puzzles produce a result which uses values '#', and '.' to mimic pixels turned on/off in a display, like below:

.##..###...##.
#..#.#..#.#..#
#..#.###..#...
####.#..#.#...
#..#.#..#.#..#
#..#.###...##.

Converting the above string into the string 'ABC' is a task which, unaccaptably, requires a human to think and type for a few seconds.

This package exposes functionality to automatically parse ASCII art-like displays like the above into strings. It can be called in two ways in python, via the aococr method, or via the aoc-ocr command-line tool.

Variations like fontsize of the ASCII glyphs and handling other characters than "#" / "." Should™ be handled automatically. If not, see the aococr docstring.

Installation

pip install aococr

In python:

from aococr import aococr

display_string = """
.##..###...##.
#..#.#..#.#..#
#..#.###..#...
####.#..#.#...
#..#.#..#.#..#
#..#.###...##.
"""

s = aococr(display_string)
print(s)  # prints "ABC"

The aococr method accepts several data types:

  • list of lists of characters
  • strings, which are stripped of trailing/leading whitespace and converted into lists of lists
  • numpy-arrays (though numpy is not a dependency)

From command line

aoc-ocr < some_file.txt

Credit

The ASCII-glyphs come from mstksg's advent-of-code-ocr Haskell library, which lists contributions to collecting the fonts to Reddit users u/usbpc102, u/TheShallowOne, and @gilgamec.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aococr-0.2.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

aococr-0.2.0-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page