Seth-McKilla / ai-crossword

Crossword generator powered by OpenAI.
https://ai-crossword.vercel.app
2 stars 1 forks source link

Implement Crossword Generation Tools #1

Open CasimirCam opened 1 year ago

CasimirCam commented 1 year ago

Setup Python side of the repository to handle crossword generation.

INPUTS:

  1. The answer bank of crossword clues (that have been properly vetted to be acceptable words of appropriate length).

  2. The side-length of the (square) puzzle area. Each character (of a word) constitutes a single length unit. The default value is 20.

Note: Will need to implement a clean handover method between various sides of the project. Perhaps via simple (~5-10 line) .ini file.

OUTPUTS:

  1. A JSON file that describes a single Python dictionary that contains key-value elements for each word provided in the answer bank. Python dictionary format:

Example:

{1: [1, 9, 'OVERWATCH', 'ACROSS'], 2: [1, 11, 'ENGINEER', 'DOWN'], 3: [2, 8, 'BUFFALO', 'DOWN']}
KEY VALUE
Clue's Numeric Index [Row Index, Column Index, Corresponding Word, Orientation]

Note: Ensure clean handoff from Python back to React / other handler.

Seth-McKilla commented 1 year ago

After researching handoff methods a bit more, it seems like our best bet will be:

  1. The puzzles NextJS api route receives user inputs (title, theme, reading level, grid size, words)
  2. Directly before creating clues, an HTTP POST request is sent to the crosswords python api route with the following JSON within the request body:
    {
    "size": 20,
    "answers": ["OVERWATCH","ENGINEER","BUFFALO"]
    }
  3. Python does its magic to either return output above or error if unable to create puzzle 3.1. If error, leave NextJS API route early and inform user that words list doesn't work, try others. 3.2. Otherwise, create clues from words, combine & format crossword & clues JSON, and send back to client to display in react-crossword component.