Skip to content

Deterministic acyclic finite state automaton in crystal

License

Notifications You must be signed in to change notification settings

baltavay/crystal-dawg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crystal-dawg

Deterministic acyclic finite state automaton in crystal

Installation

Add this to your application's shard.yml:

dependencies:
  crystal-dawg:
    github: baltavay/crystal-dawg

Usage

require "crystal-dawg"
# create dawg
dawg = Dawg.create
# add words in alphabetical order
dawg.add("taps")
dawg.add("tops")
dawg.finish

# query word
dawg.query("t")
-> [taps, tops]

# saving
Dawg.save("dawg.dawg", dawg)

# there is two variants of loading dawg structure
# 1: fast but eats more memory
dawg = Dawg.load("dawg.dawg", Dawg::Type::Fast)
# 2: little memory usage but slower
dawg = Dawg.load("dawg.dawg", Dawg::Type::Small)

Contributing

  1. Fork it ( https://github.com/baltavay/crystal-dawg/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Deterministic acyclic finite state automaton in crystal

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published