Documentation ¶
Overview ¶
Package hyphenator provides TeX-style hyphenation for multiple languages (forked from github.com/AlanQuatermain/go-hyphenator and modified).
Index ¶
- type Hyphenator
- type Trie
- func (p *Trie) AddPatternString(s string)
- func (p *Trie) AddString(s string)
- func (p *Trie) AddValue(s string, v interface{})
- func (p *Trie) AllSubstrings(s string) []string
- func (p *Trie) AllSubstringsAndValues(s string) ([]string, []interface{})
- func (p *Trie) Contains(s string) bool
- func (p *Trie) GetValue(s string) (interface{}, bool)
- func (p *Trie) Members() (members []string)
- func (p *Trie) Remove(s string) bool
- func (p *Trie) Size() (sz int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hyphenator ¶
type Hyphenator struct {
// contains filtered or unexported fields
}
Hyphenator struct itself. The nil value is a hyphenator which has not been initialized with any hyphenation patterns or language yet.
func (*Hyphenator) Hyphenate ¶
func (h *Hyphenator) Hyphenate(s, hyphen string) string
Hyphenate string.
func (*Hyphenator) LoadDictionary ¶
func (h *Hyphenator) LoadDictionary(language string, patterns, exceptions io.Reader) error
LoadDictionary imports hyphenation patterns and exceptions from provided input streams.
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
A Trie uses runes rather than characters for indexing, therefore its child key values are integers.
func (*Trie) AddPatternString ¶
AddPatternString specialized function for TeX-style hyphenation patterns. Accepts strings of the form '.hy2p'. The value it stores is of type []int
func (*Trie) AddString ¶
AddString adds a string to the trie. If the string is already present, no additional storage happens. Yay!
func (*Trie) AddValue ¶
AddValue adds a string to the trie, with an associated value. If the string is already present, only the value is updated.
func (*Trie) AllSubstrings ¶
AllSubstrings returns all anchored substrings of the given string within the Trie.
func (*Trie) AllSubstringsAndValues ¶
AllSubstringsAndValues returns all anchored substrings of the given string within the Trie, with a matching set of their associated values.
func (*Trie) GetValue ¶
GetValue returns the value associated with the given string. Double return: false if the given string was not present, true if the string was present. The value could be both valid and nil.