dawg

package module
v0.0.0-...-aadae81 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2013 License: MIT Imports: 8 Imported by: 2

README

dawg

Directed Acyclic Word Graph implementation in Go, with fuzzy search of words in the graph.

Usage

Import the library:

import "github.com/ftbe/dawg"

Use it:

    graph, err := dawg.CreateDAWGFromFile(os.Args[1])
    if err != nil {
        // Do something
        return
    }
    words, err := graph.Search("aging", 2, 50, true, true)
    if err != nil {
        // Do something
        return
    }
    for _, word := range words {
        fmt.Println(word)
    }

Documentation

API documentation is available on godoc.

Documentation

Overview

Package dawg implements a Directed Acyclic Word Graph, with fuzzy search of words in the graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAWG

type DAWG struct {
	// contains filtered or unexported fields
}

DAWG is used to store the representation of the Directly Acyclic Word Graph

func CreateDAWG

func CreateDAWG(words []string) *DAWG

Create a new DAWG by loading the words from an array.

func CreateDAWGFromFile

func CreateDAWGFromFile(fileName string) (dawg *DAWG, err error)

Create a new DAWG by loading the words from a file. The file must be UTF-8 encoded, one word per line.

func LoadDAWGFromFile

func LoadDAWGFromFile(fileName string) (dawg *DAWG, err error)

Load from a file a DAWG saved by SaveToFile

func (*DAWG) FindRandomWord

func (dawg *DAWG) FindRandomWord(wordSize int) (string, error)

func (*DAWG) SaveToFile

func (dawg *DAWG) SaveToFile(fileName string) (err error)

Save the DAWG to a file, usefull if you want to load it later without re-computing anything

func (*DAWG) Search

func (dawg *DAWG) Search(word string, levenshteinDistance int, maxResults int, allowAdd bool, allowDelete bool) (words []string, err error)

Approximate string searching in the DAWG. levenshteinDistance is the maximum Levenshtein distance allowed beetween word and the words found in the DAWG. maxResults allow to limit the number of returned results (to reduce the time needed by the search) allowAdd and allowDelete specify if the returned words can have insertions/deletions of letters

Jump to

Keyboard shortcuts

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