|
OCR Project
|
8-direction crossword word-search solver. More...

Macros | |
| #define | N_DIRS 8 |
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 *g) |
| Print a CharGrid to stdout (for debugging / verbose mode). | |
| void | grid_free (CharGrid *g) |
| Free a CharGrid. | |
| static int | try_direction (const CharGrid *grid, const char *word, int r, int c, int dir) |
Check whether word fits in grid starting at (r, c) going in direction dir. | |
| 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. | |
Variables | |
| static const int | DIR_DR [N_DIRS] = { 0, 1, 1, 1, 0, -1, -1, -1} |
| Row and column deltas for each of the 8 search directions. | |
| static const int | DIR_DC [N_DIRS] = { 1, 1, 0, -1, -1, -1, 0, 1} |
| static const char * | DIR_NAMES [N_DIRS] |
8-direction crossword word-search solver.
| #define N_DIRS 8 |
Number of search directions.
| 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). |


|
static |
Check whether word fits in grid starting at (r, c) going in direction dir.
| grid | Character grid. |
| word | Uppercase null-terminated search string. |
| r | Starting row. |
| c | Starting column. |
| dir | Direction index (0–7). |

|
static |
|
static |
Row and column deltas for each of the 8 search directions.
Indexed 0–7: 0 = RIGHT (dr= 0, dc=+1) 1 = DOWN_RIGHT (dr=+1, dc=+1) 2 = DOWN (dr=+1, dc= 0) 3 = DOWN_LEFT (dr=+1, dc=-1) 4 = LEFT (dr= 0, dc=-1) 5 = UP_LEFT (dr=-1, dc=-1) 6 = UP (dr=-1, dc= 0) 7 = UP_RIGHT (dr=-1, dc=+1)
|
static |