colltab

package
v0.0.0-...-2bc18d8 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: BSD-2-Clause, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package colltab contains functionality related to collation tables. It is only to be used by the collate and search packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchLang

func MatchLang(t language.Tag, tags []language.Tag) int

MatchLang finds the index of t in tags, using a matching algorithm used for collation and search. tags[0] must be language.Und, the remaining tags should be sorted alphabetically.

Language matching for collation and search is different from the matching defined by language.Matcher: the (inferred) base language must be an exact match for the relevant fields. For example, "gsw" should not match "de". Also the parent relation is different, as a parent may have a different script. So usually the parent of zh-Hant is und, whereas for MatchLang it is zh.

Types

type Iter

type Iter struct {
	Weighter colltab.Weighter
	Elems    []colltab.Elem
	// N is the number of elements in Elems that will not be reordered on
	// subsequent iterations, N <= len(Elems).
	N int
	// contains filtered or unexported fields
}

An Iter incrementally converts chunks of the input text to collation elements, while ensuring that the collation elements are in normalized order (that is, they are in the order as if the input text were normalized first).

func (*Iter) Discard

func (i *Iter) Discard()

Discard removes the collation elements up to N.

func (*Iter) End

func (i *Iter) End() int

End returns the end position of the input text for which Next has returned results.

func (*Iter) Len

func (i *Iter) Len() int

Len returns the length of the input text.

func (*Iter) Next

func (i *Iter) Next() bool

Next appends Elems to the internal array. On each iteration, it will either add starters or modifiers. In the majority of cases, an Elem with a primary value > 0 will have a CCC of 0. The CCC values of collation elements are also used to detect if the input string was not normalized and to adjust the result accordingly.

func (*Iter) Reset

func (i *Iter) Reset(p int)

Reset sets the position in the current input text to p and discards any results obtained so far.

func (*Iter) SetInput

func (i *Iter) SetInput(s []byte)

SetInput resets i to input s.

func (*Iter) SetInputString

func (i *Iter) SetInputString(s string)

SetInputString resets i to input s.

Jump to

Keyboard shortcuts

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