anagrammer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package anagrammer uses a DAWG instead of a GADDAG to simplify the algorithm and make it potentially faster - we don't need a GADDAG to generate anagrams/subanagrams.

This package generates anagrams and subanagrams and has an RPC interface.

blank_challenges has utilities for generating racks with blanks that have 1 or more solutions.

Index

Constants

Variables

View Source
var AuthorizationKey = os.Getenv("AUTH_KEY")

AuthorizationKey is used for non-user exposed methods

Functions

func Anagram

func Anagram(letters string, gd *gaddag.SimpleGaddag, mode AnagramMode) []string

func LoadDawgs added in v0.0.6

func LoadDawgs(dawgPath string)

Types

type AnagramMode added in v0.0.5

type AnagramMode int
const (
	ModeBuild AnagramMode = iota
	ModeExact
	ModePattern
)

type AnagramService added in v0.0.2

type AnagramService struct{}

func (*AnagramService) Anagram added in v0.0.2

func (*AnagramService) BlankChallenge added in v0.0.6

func (a *AnagramService) BlankChallenge(r *http.Request, args *BlankChallengeArgs,
	reply *BlankChallengeReply) error

func (*AnagramService) BuildChallenge added in v0.0.7

func (a *AnagramService) BuildChallenge(r *http.Request, args *BuildChallengeArgs,
	reply *BuildChallengeReply) error

type AnagramServiceArgs added in v0.0.2

type AnagramServiceArgs struct {
	Lexicon   string `json:"lexicon"`
	Letters   string `json:"letters"`
	Mode      string `json:"mode"`
	AuthToken string `json:"authToken"`
}

type AnagramServiceReply added in v0.0.2

type AnagramServiceReply struct {
	Words    []string `json:"words"`
	NumWords int      `json:"numWords"`
}

type AnagramStruct added in v0.0.6

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

type BlankChallengeArgs added in v0.0.6

type BlankChallengeArgs struct {
	WordLength   int    `json:"wordLength"`
	NumQuestions int    `json:"numQuestions"`
	Lexicon      string `json:"lexicon"`
	MaxSolutions int    `json:"maxSolutions"`
	// How many to generate with 2 blanks (default is 1)
	Num2Blanks int `json:"num2Blanks"`
}

type BlankChallengeReply added in v0.0.6

type BlankChallengeReply struct {
	Questions    []*Question `json:"questions"`
	NumQuestions int         `json:"numQuestions"`
	NumAnswers   int         `json:"numAnswers"`
}

type BuildChallengeArgs added in v0.0.7

type BuildChallengeArgs struct {
	WordLength            int    `json:"wordLength"`
	MinWordLength         int    `json:"minWordLength"`
	RequireLengthSolution bool   `json:"requireLengthSolution"`
	Lexicon               string `json:"lexicon"`
	MinSolutions          int    `json:"minSolutions"`
	MaxSolutions          int    `json:"maxSolutions"`
}

type BuildChallengeReply added in v0.0.7

type BuildChallengeReply struct {
	Question   *Question `json:"question"`
	NumAnswers int       `json:"numAnswers"`
}

type Question added in v0.0.6

type Question struct {
	Q string   `json:"q"`
	A []string `json:"a"`
}

func GenerateBlanks added in v0.0.6

func GenerateBlanks(ctx context.Context, args *BlankChallengeArgs,
	dawg *gaddag.SimpleGaddag) ([]*Question, int, error)

GenerateBlanks - Generate a list of blank word challenges given the parameters in args.

func GenerateBuildChallenge added in v0.0.7

func GenerateBuildChallenge(ctx context.Context, args *BuildChallengeArgs,
	dawg *gaddag.SimpleGaddag) (*Question, int, error)

GenerateBuildChallenge generates a build challenge with given args. As an additional condition, letters must anagram exactly to at least one word, if that argument is passed in.

Jump to

Keyboard shortcuts

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