hyphenator

package
v1.58.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: GPL-3.0, BSD-3-Clause Imports: 7 Imported by: 0

README

Note:

	github.com/AlanQuatermain/go-trie
	github.com/AlanQuatermain/go-hyphenator

Original code is very outdated (due to heavy language changes) and probably was never tested with non-English dictionaries.
I was not able to use it without fixes and modifications. I have no plans to submit PR (due to the age of original repositories)
or publish fixes separately from this program...

For sanity sake I retained original COPYRIGHT content in a separate file in this directory.

Documentation

Overview

Package hyphenator provides TeX-style hyphenation for multiple languages (forked from github.com/AlanQuatermain/go-hyphenator and modified).

Index

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 NewTrie

func NewTrie() *Trie

NewTrie creates and returns a new Trie instance.

func (*Trie) AddPatternString

func (p *Trie) AddPatternString(s string)

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

func (p *Trie) AddString(s string)

AddString adds a string to the trie. If the string is already present, no additional storage happens. Yay!

func (*Trie) AddValue

func (p *Trie) AddValue(s string, v interface{})

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

func (p *Trie) AllSubstrings(s string) []string

AllSubstrings returns all anchored substrings of the given string within the Trie.

func (*Trie) AllSubstringsAndValues

func (p *Trie) AllSubstringsAndValues(s string) ([]string, []interface{})

AllSubstringsAndValues returns all anchored substrings of the given string within the Trie, with a matching set of their associated values.

func (*Trie) Contains

func (p *Trie) Contains(s string) bool

Contains tests for the inclusion of a particular string in the Trie.

func (*Trie) GetValue

func (p *Trie) GetValue(s string) (interface{}, bool)

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.

func (*Trie) Members

func (p *Trie) Members() (members []string)

Members retrieves all member strings, in order.

func (*Trie) Remove

func (p *Trie) Remove(s string) bool

Remove a string from the trie. Returns true if the Trie is now empty.

func (*Trie) Size

func (p *Trie) Size() (sz int)

Size counts all the nodes of the entire Trie, NOT including the root node.

Jump to

Keyboard shortcuts

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