correctors

package
v0.0.0-...-0c294a2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SwitchAll          = "swc-all"
	RemoveLast         = "rm-last"
	SwitchFirst        = "swc-first"
	RemoveFirst        = "rm-first"
	SwitchLast         = "sws-last1"
	SwitchLastN        = "sws-lastn"
	UpperNCapital      = "upncap"
	NumberToSymbolLast = "n2s-last"
	Capital2Upper      = "cap2up"
	AddOneLast         = "add1-last"
)

Corrector constants

Variables

View Source
var LetterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?")

TODO extend to use any rune instead of US alphanumerics

Functions

func AppendOne

func AppendOne(password string) string

AppendOne adds a 1 to the password add1_last

func ApplyCorrectionFunction

func ApplyCorrectionFunction(corrector string, password string) string

ApplyCorrectionFunction applies the appropriate corrector function given it's config name

func ApplyInverseCorrectionFunction

func ApplyInverseCorrectionFunction(corrector string, password string) []string

ApplyInverseCorrectionFunction applies the appropriate corrector function given it's config name

func CapitalToUpper

func CapitalToUpper(password string) string

CapitalToUpper returns the password with every letter capitalised. For when users press shift-key instead of caps-lock cap2up

func ConvertLastNumberToSymbol

func ConvertLastNumberToSymbol(password string) string

ConvertLastNumberToSymbol converts the last number to a symbol - TODO should depend on keyboard layout n2s-last

func ConvertLastSymbolToNumber

func ConvertLastSymbolToNumber(password string) string

ConvertLastNumberToSymbol converts the last number to a symbol - TODO should depend on keyboard layout s2n-last

func DeleteEmpty

func DeleteEmpty(s []string) []string

DeleteEmpty remove all empty strings from a slice

func GetBall

func GetBall(password string, correctors []string) []string

GetBall returns the passwords in the ball given a slice of correctors

func GetBallWithCorrectionType

func GetBallWithCorrectionType(password string, correctors []string) map[string]string

GetBallWithCorrectionType returns the ball with the correction type string

func GetNBestCorrectors

func GetNBestCorrectors(n int, typoFrequency map[string]int) []string

GetNBestCorrectors returns the n best correctors in order, determined by the typo frequency

func InverseRemoveFirst

func InverseRemoveFirst(password string) []string

InverseRemoveFirst prepends every rune to the password

func InverseRemoveLast

func InverseRemoveLast(password string) []string

InverseRemoveLast appends every rune to the password

func RemoveFirstChar

func RemoveFirstChar(password string) string

RemoveFirstChar removes the first character from the string rm-first

func RemoveLastChar

func RemoveLastChar(password string) string

RemoveLastChar removes the last character from the string rm-last

func Same

func Same(password string) string

Same is the identity function

func StringInSlice

func StringInSlice(s string, list []string) bool

StringInSlice returns true if s in is list

func SwitchCaseAll

func SwitchCaseAll(password string) string

SwitchCaseAll switches the case of all the letters in the string swc-all

func SwitchCaseFirstLetter

func SwitchCaseFirstLetter(password string) string

SwitchCaseFirstLetter switches the case of the first letter in the string to upper case swc-first

func SwitchShiftLastCharacter

func SwitchShiftLastCharacter(password string) string

SwitchShiftLastCharacter changes the last character according to the appropriate shift modifier sws-last1

func SwitchShiftLastNCharacters

func SwitchShiftLastNCharacters(password string, n int) string

SwitchShiftLastNCharacters changes the last n characters according to the appropriate shift modifier sws-lastn

func UpperToCapital

func UpperToCapital(password string) string

UpperToCapital returns the password with every letter capitalised. For when users press caps-lock instead of shift up2cap

Types

type KeyValue

type KeyValue struct {
	Key   string
	Value int
}

KeyValue reporesents a map as a slice

func ConvertMapToSortedSlice

func ConvertMapToSortedSlice(in map[string]int) []KeyValue

ConvertMapToSortedSlice converts a map to a slice and sorts it by value

Jump to

Keyboard shortcuts

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