Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
A Builder builds a root collation table. The user must specify the collation elements for each entry. A common use will be to base the weights on those specified in the allkeys* file as provided by the UCA or CLDR.
func (*Builder) Add ¶
Add adds an entry to the collation element table, mapping a slice of runes to a sequence of collation elements. A collation element is specified as list of weights: []int{primary, secondary, ...}. The entries are typically obtained from a collation element table as defined in https://www.unicode.org/reports/tr10/#Data_Table_Format. Note that the collation elements specified by colelems are only used as a guide. The actual weights generated by Builder may differ. The argument variables is a list of indices into colelems that should contain a value for each colelem that is a variable. (See the reference above.)
type Tailoring ¶
type Tailoring struct {
// contains filtered or unexported fields
}
A Tailoring builds a collation table based on another collation table. The table is defined by specifying tailorings to the underlying table. See https://unicode.org/reports/tr35/ for an overview of tailoring collation tables. The CLDR contains pre-defined tailorings for a variety of languages (See https://www.unicode.org/Public/cldr/<version>/core.zip.)
func (*Tailoring) Insert ¶
Insert sets the ordering of str relative to the entry set by the previous call to SetAnchor or Insert. The argument extend corresponds to the extend elements as defined in LDML. A non-empty value for extend will cause the collation elements corresponding to extend to be appended to the collation elements generated for the entry added by Insert. This has the same net effect as sorting str after the string anchor+extend. See https://www.unicode.org/reports/tr10/#Tailoring_Example for details on parametric tailoring and https://unicode.org/reports/tr35/#Collation_Elements for full details on LDML.
Examples: create a tailoring for Swedish, where "ä" is ordered after "z" at the primary sorting level:
t := b.Tailoring("se") t.SetAnchor("z") t.Insert(colltab.Primary, "ä", "")
Order "ü" after "ue" at the secondary sorting level:
t.SetAnchor("ue") t.Insert(colltab.Secondary, "ü","")
or
t.SetAnchor("u") t.Insert(colltab.Secondary, "ü", "e")
Order "q" after "ab" at the secondary level and "Q" after "q" at the tertiary level:
t.SetAnchor("ab") t.Insert(colltab.Secondary, "q", "") t.Insert(colltab.Tertiary, "Q", "")
Order "b" before "a":
t.SetAnchorBefore("a") t.Insert(colltab.Primary, "b", "")
Order "0" after the last primary ignorable:
t.SetAnchor("<last_primary_ignorable/>") t.Insert(colltab.Primary, "0", "")
func (*Tailoring) SetAnchor ¶
SetAnchor sets the point after which elements passed in subsequent calls to Insert will be inserted. It is equivalent to the reset directive in an LDML specification. See Insert for an example. SetAnchor supports the following logical reset positions: <first_tertiary_ignorable/>, <last_teriary_ignorable/>, <first_primary_ignorable/>, and <last_non_ignorable/>.
func (*Tailoring) SetAnchorBefore ¶
SetAnchorBefore is similar to SetAnchor, except that subsequent calls to Insert will insert entries before the anchor.