Skip to content

About

A python script to solve wordsearch puzzles, fitted with Pytesseract OCR and Tkinter GUI.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordsearchPlus

A python script to solve wordsearch puzzles, fitted with Pytesseract OCR and Tkinter GUI. What initialy began as a simple, console-based, class project became a personal side project with periodic developments.


Input

WordsearchPlus takes 2 PNG images as input, the puzzle grid and the list of words, and uses OpenCV and Pytesseract for image pre-processing and OCR.

Wordsearch Grid Wordsearch Grid

The letter grid and word list are displayed on a Tkinter GUI for the user to validate the grid/list and make edits in case the OCR misread any characters. The user also has the ability to add or delete rows and columns of the letter grid as well as add or remove words from the word list. Upon completing all necessary edits (if any), the user submits the grid and list for the algorithm to search for all the words in the grid. The grid is displayed again but with the words highlighted in the grid.

Input GUI

Points of Improvement:

  • Add a layer of ML to extract the letter grid and word list from a single image

Search Algorithm

The search aglorithm traverses through the grid for each word in the list. When the first letter of the word is encountered, the algorithm checks the surrounding letters and seeks the rest of the word. A list of letter positions is returned to the output interface.

WordsearchPlus/algo.py

Lines 8 to 27 in 0c088a8

for word in word_list:
for x in range(rows):
for y in range(cols):
if word_board[x][y] == word[0]:
for dir in directions:
temp_coords = [(x, y)]
build = word_board[x][y]
row = x
col = y
for i in range(1, len(word)):
row += dir[0]
col += dir[1]
if (row >= 0 and col >= 0 and row < rows and col < cols):
if (word_board[row][col] == word[i]):
temp_coords.append((row, col))
build += word[i]
if build == word:
word_coords += temp_coords
print(build)
break

Points of Improvement:

  • Clearly, the algorithm is highly inefficient from a time complexity standpoint. Possible improvements could be removing redundant grid traversal.

Output

The output interface displays the letter grid that the user submitted but with the letters highlighted in yellow to indicate that they are part of a word.

Input GUI

Points of Improvement:

  • Highlighting each word its own color to avoid confusion between words; however, there is an issue of which color overlapping letters should be.

About

A python script to solve wordsearch puzzles, fitted with Pytesseract OCR and Tkinter GUI.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages