lib

package
v0.0.0-...-6a3fd6a Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(s []string, punctuations string, alphabet []string) []string

Normalize takes a bunch of strings and uses a normalization procedure to return a new set of strings.

Normalization works by identifying substrings that only ever appear together in all the provided input strings. (Punctuations are considered as effectively breaking strings). It then assigns a unique letter for each prefix -- the letter is assigned in order in which the prefix appears (those in earlier strings are considered earlier prefixes and those in latter strings are considerd latter; and within a string, an earlier prefix gets an earlier alphabet)

This process indirectly helps with identifying if two sequences of strings are "isomorphic" by comparing if their normalized forms are the same.

Note that this process is quite fragile. For example, it is not legal to have a string that has any characters duplicated. If that happens, the behavior is random.

Types

type Compact

type Compact struct{}

Compact implements some helper routines for working with the compact form as defined in CompactJSON.md

func (Compact) Apply

func (c Compact) Apply(input string, ch changes.Change) string

Apply takes a single change and applies to the input string

func (Compact) Decode

func (Compact) Decode(s string) (string, changes.Change)

Decode takes a compact form string and converts it to a changes.Change

func (Compact) Encode

func (c Compact) Encode(input string, ch changes.Change) []string

Encode takes an input and a set of changes and converts it into the compact form

func (Compact) Encode1

func (c Compact) Encode1(input string, ch changes.Change) string

Encode1 is like Encode but it only takes one change

func (Compact) Stringify

func (c Compact) Stringify(x interface{}) string

Stringify converts a string-like value to string

type Moves

type Moves struct {
	Input string
}

Moves implements a bunch of useful utiities for working with moves

func (*Moves) EncodeCompact

func (m *Moves) EncodeCompact(offset, count, distance int) string

EncodeCompact encodes a move into a compact format

func (*Moves) ForEach

func (m *Moves) ForEach(fn func(string))

ForEach generates all possible move operations for the given input string and calls the provided callback with the op encoded as in this spec: http://github.com/dotchain/dataset/CompactJSON.md

func (*Moves) ForEachPair

func (m *Moves) ForEachPair(fn func(left, right string))

ForEachPair generates pairs of operations

func (*Moves) ForEachUniquePair

func (m *Moves) ForEachUniquePair(alphabet []string, fn func(string, string, string))

ForEachUniquePair generates only unique pairs of operations and uses the provided alphabet for the "uniqueness" calculation

type Splices

type Splices struct {
	Input   string
	Inserts []string
}

Splices implements a bunch of useful utiities for working with splices

func (*Splices) EncodeCompact

func (s *Splices) EncodeCompact(offset int, before, after string) string

EncodeCompact encodes a splice into a compact format

func (*Splices) ForEach

func (s *Splices) ForEach(fn func(string))

ForEach generates all possible splice operations for the given input string and calls the provided callback with the splice encoded as in this spec: http://github.com/dotchain/dataset/CompactJSON.md

func (*Splices) ForEachPair

func (s *Splices) ForEachPair(fn func(left, right string))

ForEachPair generates pairs of operations

func (*Splices) ForEachUniquePair

func (s *Splices) ForEachUniquePair(alphabet []string, fn func(string, string, string))

ForEachUniquePair generates only unique pairs of operations and uses the provided alphabet for the "uniqueness" calculation

func (*Splices) ForEachUniqueSpliceMovePair

func (s *Splices) ForEachUniqueSpliceMovePair(alpha []string, fn func(string, string, string))

ForEachUniqueSpliceMovePair generates only unique pairs of operations and uses the provided alphabet for the "uniqueness" calculation

Jump to

Keyboard shortcuts

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