|
OCR Project
|
Crossword word-search solver: find words in a 2-D character grid in all 8 directions. More...
#include <stddef.h>

Go to the source code of this file.
Classes | |
| struct | CharGrid |
| A rectangular character grid. More... | |
| struct | WordResult |
| Result of a single word search. More... | |
Functions | |
| CharGrid * | grid_create (int rows, int cols) |
| Allocate a CharGrid of the given dimensions, filled with spaces. | |
| void | grid_fill (CharGrid *grid, const int *labels, size_t count) |
| Fill a CharGrid from an array of predicted character indices. | |
| CharGrid * | grid_load (const char *path) |
| Read a CharGrid from a plain-text file. | |
| void | grid_print (const CharGrid *grid) |
| Print a CharGrid to stdout (for debugging / verbose mode). | |
| void | grid_free (CharGrid *grid) |
| Free a CharGrid. | |
| WordResult | solver_find (const CharGrid *grid, const char *word) |
Search for word in grid in all 8 directions. | |
| const char * | solver_dir_name (int dir) |
Return the human-readable name of direction index dir. | |
Crossword word-search solver: find words in a 2-D character grid in all 8 directions.
The character grid is built from the CNN's predictions after segmentation: each cell in the crossword image yields one predicted character (A–Z). The solver then searches for user-supplied words in the resulting grid.
Directions (clockwise from East): RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, UP_LEFT, UP, UP_RIGHT
| CharGrid * grid_create | ( | int | rows, |
| int | cols ) |
Allocate a CharGrid of the given dimensions, filled with spaces.
| rows | Number of rows. |
| cols | Number of columns. |

| void grid_fill | ( | CharGrid * | grid, |
| const int * | labels, | ||
| size_t | count ) |
Fill a CharGrid from an array of predicted character indices.
| grid | Target grid (must already be allocated with the right size). |
| labels | Array of class indices in [0, 25]; labels[r*cols + c] gives the index for cell (r, c). 0='A', 25='Z'. |
| count | Number of elements in labels (must equal rows * cols). |

| void grid_free | ( | CharGrid * | grid | ) |
Free a CharGrid.
| grid | Grid to free. No-op if NULL. |

| CharGrid * grid_load | ( | const char * | path | ) |
Read a CharGrid from a plain-text file.
File format (first line: dimensions, then one row per line):
| path | Path to the grid file. |

| void grid_print | ( | const CharGrid * | grid | ) |
Print a CharGrid to stdout (for debugging / verbose mode).
| grid | Grid to display. |

| const char * solver_dir_name | ( | int | dir | ) |
Return the human-readable name of direction index dir.
Directions are numbered 0–7: 0=RIGHT, 1=DOWN_RIGHT, 2=DOWN, 3=DOWN_LEFT, 4=LEFT, 5=UP_LEFT, 6=UP, 7=UP_RIGHT
| dir | Direction index in [0, 7]. |

| WordResult solver_find | ( | const CharGrid * | grid, |
| const char * | word ) |
Search for word in grid in all 8 directions.
The search is case-insensitive; the grid and word are both converted to uppercase before comparison.
| grid | Character grid to search in. |
| word | Null-terminated string to search for (A–Z, case-insensitive). |

