Project

gaddag

0.0
No commit activity in last 3 years
No release in over 3 years
Implementation of the GADDAG data structure
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5.1
~> 0.4.5
~> 0.5.11
~> 0.5.10
>= 0
>= 0
~> 2.14.1
~> 0.8.7

Runtime

~> 0.0.9
 Project Readme

GADDAG data structure in Ruby

A GADDAG is a data structure that allows for fast lookup of words by substring. It is a directed acyclic graph, where each word can be constructed from the root via any of its reversed prefixes. Its main application is move generation in Scrabble. The data structure is explained in more detail in the original research paper.

Gem Version Build Status Dependency Status Code Climate

Installation

The gaddag gem is available via Rubygems. Install the gem by adding it to your Gemfile or by running:

gem install gaddag

Usage

Initializing the GADDAG is simple:

require 'gaddag'
gaddag = GADDAG.new

Adding words is done via the add method. This will expand the graph with paths for all the reversed prefixes of the word. Note that this may take some time when adding a large number of words.

File.readlines('/usr/share/dict/words') do |word|
  gaddag.add(word.strip) if word.strip.length == 10 # => #<Gaddag:0x007fc6c24367b0 ... >
end

In order to find all words that contain a given substring, use the find method:

gaddag.find('elevi') => # ["televiewer", "television", "televisual"]

Examples

License

See LICENSE.txt.