wordjumble

command module
v0.0.0-...-39110ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 19 Imported by: 0

README

Word Jumble

A little command-line tool to solve word games like New York Times Spelling Bee. By default, the reuse of letters is permitted. The -c (--consume) flag disables letter reuse, making it suitable for Scrabble or similar games.

Usage

Test one or more strings
wordjumble \
  [-v|--verbose] \
  [-c|--consume] \
  [-d|--dict <dictionary>] \
  [--use-array] \
  string_1 [string_2] [string_...] [string_n]

This will launch wordjumble loading the specified dictionary (or using the default 2of12inf). Each string will be checked against the dictionary, separated by ------. The --dict parameter can be used with any of the dictionaries from the list command (see below). The --consume parameter disables letter reuse unless the letter is explicitly duplicated in the input. The --use-array parameter tells the application to use the arraytrie implementation instead of the maptrie implementation.

Example
$ ./wordjumble abc def
baa
cab
------
deed
deeded
def
ed
fed
fee
feed
$ ./wordjumble -c abc def
cab
------
def
ed
REPL mode

If no strings are provided, the application will present you with a prompt, word>. This is REPL (read-evaluate-print loop) mode. Strings can be entered here and they will be processed as normal. Exit the REPL with ^C or enter on an empty line.

./wordjumble
Loaded dictionary 2of12inf: 81,883 words
words> abc
baa
cab
words> def
deed
deeded
def
ed
fed
fee
feed
words>
List internal dictionaries
wordjumble list
Example (List)
$ ./wordjumble list
2of12
2of12inf
3esl
6of12
scrabble_words
words_alpha

Implementation

There are two implementations in this application, both based on a trie structure -- An array-based trie or a map-based trie. For only unaccented Latin characters, the array-based true should be faster, but if you want to support dictionaries with large character sets, the array can take multiple steps per character. This is where the map-based implementation is possibly more effective. I haven't put any non-Latin dictionaries into the code, but the reason for this little toy was to play around with exactly that.

These trie implementations have another problem: false positives. Because each rune is split into bytes, the bytes of a particular rune are not held together. That means that the the implementation can return incorrect results. The most correct form would be a map of tries based on runes, though that would have a different interface.

Dictionaries

The effectiveness of this kind of tool is tied to how well the dictionary matches the dictionary in the game. To that end, I've included a couple of different dictionaries.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL