Skip to main content

Codenames Parser

PyPI version Pipeline codecov Ruff Code style: black Imports: isort Type checked: mypy Linting: pylint

A Python package to parse Codenames game boards from images.
Before we dive in, here are some examples:

Color map extraction

Given color_map.png:

Running:

python -m codenames_parser/color_map/entrypoint.py color_map.png classic

Outputs:

Some parsing logs...

# As emoji table
⬜ 🟥 🟦 🟦 🟥
⬜ 🟦 🟥 ⬜ 🟦
🟦 🟥 🟥 🟦 ⬜
🟦 🟥 🟥 ⬜ ⬜
⬜ 🟦 💀 🟥 🟦

# As list
['NEUTRAL', 'RED', 'BLUE', 'BLUE', 'RED', 'NEUTRAL', 'BLUE', 'RED', 'NEUTRAL', 'BLUE', 'BLUE', 'RED', 'RED', 'BLUE', 'NEUTRAL', 'BLUE', 'RED', 'RED', 'NEUTRAL', 'NEUTRAL', 'NEUTRAL', 'BLUE', 'ASSASSIN', 'RED', 'BLUE']

Board extraction

"Life is not perfect, neither is OCR" (credit: Github Copilot)

Given board.png:

Running:

python -m codenames_parser/board/entrypoint.py board.png heb

Outputs:

Some parsing logs...

# As table
+-------+---------+-------+-------+------+
| ציבור | אוטובוס | ישראל |  מתח  |  גס  |
+-------+---------+-------+-------+------+
| ברית  |   גוש   | איום  | מורח  | קנה  |
+-------+---------+-------+-------+------+
| לידה  |  מבחן   | אודם  | שוקו  | חטיף |
+-------+---------+-------+-------+------+
|  חוק  |   רץ    | חצות  | רדיו  | כתם  |
+-------+---------+-------+-------+------+
|  גרם  |   כהן   | רושם  | אלמוג |      |
+-------+---------+-------+-------+------+

# As list
[
    "ציבור",    "אוטובוס",    "ישראל",    "מתח",    "גס",
    "ברית",    "גוש",    "איום",    "מורח",    "קנה",
    "לידה",    "מבחן",    "אודם",    "שוקו",    "חטיף",
    "חוק",    "רץ",    "חצות",    "רדיו",    "כתם",
    "גרם",    "כהן",    "רושם",    "אלמוג",     "",
]

* It looks as if the direction of the board is flipped. This is a bug due to Hebrew being written from right to left, the list order is correct.

Installation

pip install codenames-parser

OCR

  1. Uses pytesseract to extract text from images.
  2. Requires tesseract to be installed on the system ( see installing-tesseract).
  3. Download more languages from: https://github.com/tesseract-ocr/tessdata

Release files for codenames-parser 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codenames-parser 1.0.4
File Size Uploaded
codenames_parser-1.0.4.tar.gz 35.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codenames-parser 1.0.4
File Interpreter ABI Platform
codenames_parser-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 80.1 kB

Release files / codenames_parser-1.0.4.tar.gz

Download URL codenames_parser-1.0.4.tar.gz
Size 35.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7ccecac47d1fd3d79604fc78850dbb16221cf8669c09703cde8f4f7d1aa4b7e5
BLAKE2b-256 checksum
How to use checksums
d8d6f5a6c2e1e93c910a369ab6a34dfcbb820ff90e50470e3c90ea0e4983c692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2024.

Transparency log

Release files / codenames_parser-1.0.4-py3-none-any.whl

Download URL codenames_parser-1.0.4-py3-none-any.whl
Size 44.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38db0f99e58f6fd3353a7f3caeab1753348f7b1d0f5d1b984ee0ecaa1ba0095e
BLAKE2b-256 checksum
How to use checksums
e123f4dfd5b3520252c12a72b7b88cb70a2627eda80c07462c3cfc975ebd7efa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page