domain

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsOriginal added in v1.1.0

func AsOriginal(abbr Abbreviator, original string, max int, frmFront bool, rmvStop bool) string

AsOriginal discovers words using camel case and non letter characters, starting from the back or the front until the string has less than 'max' characters or it can't shorten any more.

func AsPascal added in v1.1.0

func AsPascal(abbr Abbreviator, original string, max int, frmFront bool, rmvStop bool) string

AsPascal discovers words using camel case and non letter characters, starting from the back or the front until the string has less than 'max' characters or it can't shorten any more. Word boundaries are a capital letter at the start of each word

func AsSeparated added in v1.4.0

func AsSeparated(abbr Abbreviator, original, separator string, max int, frmFront bool, rmvStop bool) string

AsSeparated discovers words using camel case and non letter characters, starting from the back or the front until the string has less than 'max' characters or it can't shorten any more. This inserts the specified separator where a sequence is not alpha-numeric

Types

type Abbreviator added in v1.4.0

type Abbreviator interface {
	// Abbreviate attempts to return an abbreviation for the word given. It
	// does not guarantee to return a different, shorter string.
	Abbreviate(word string) string
}

Abbreviator allows you to use different implementations for abbreviating words

type Matcher

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

Matcher finds matches between words and abbreviations

func NewMatcher added in v1.3.0

func NewMatcher(mainWords, prefixes, suffixes map[string]string) *Matcher

NewMatcher creates a new matcher of abbreviation mappings

func NewMatcherFromString

func NewMatcherFromString(data string) *Matcher

NewMatcherFromString creates a new matcher from newline seperated data

func (*Matcher) Abbreviate added in v1.4.0

func (matcher *Matcher) Abbreviate(word string) string

Abbreviate returns an abbreviation looked up from pre-defined mappings

func (Matcher) All added in v1.2.0

func (matcher Matcher) All() []string

All of the abbreviations in this set in order of the linked word

func (Matcher) Match

func (matcher Matcher) Match(word string) string

Match against a list of mappings

type NoAbbreviator added in v1.4.0

type NoAbbreviator struct{}

NoAbbreviator does not abbreviate anything

func (*NoAbbreviator) Abbreviate added in v1.4.0

func (a *NoAbbreviator) Abbreviate(word string) string

Abbreviate just returns the unabbreviated word

type Sequences

type Sequences []string

Sequences represents a string that has been broken in to different parts of words and separators

func NewSequences

func NewSequences(original string) Sequences

NewSequences generates a new Sequences from the string passed in

func (*Sequences) AddBack

func (all *Sequences) AddBack(str string)

AddBack adds a new string to the back of the Sequences

func (*Sequences) AddFront

func (all *Sequences) AddFront(str string)

AddFront adds a new string to the front of the Sequences

func (*Sequences) IsSeparator added in v1.6.0

func (all *Sequences) IsSeparator(pos int) bool

IsSeparator checks if the string at position pos is a separator

func (Sequences) Len

func (all Sequences) Len() int

Len gives the number of sequences found

func (*Sequences) Pop added in v1.6.0

func (all *Sequences) Pop()

Pop deletes the last string in the Sequences

func (*Sequences) RemoveStopwords added in v1.6.0

func (all *Sequences) RemoveStopwords()

RemoveStopwords removes stopwords in the Sequences, and separators that precedes a stopword

func (Sequences) String

func (all Sequences) String() string

type Shortener

type Shortener func(matcher Matcher, original string, max int) string

Shortener represents an algorithm that can be used to shorten a string by substituting words for abbreviations

Jump to

Keyboard shortcuts

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