Documentation
¶
Overview ¶
Package telex implements text processing for Vietnamese
Index ¶
- Constants
- Variables
- func AddMarkToChar(chr rune, mark uint8) rune
- func AddMarkToTonelessChar(chr rune, mark uint8) rune
- func AddToneToChar(chr rune, tone uint8) rune
- func Encode(charsetName string, input string) string
- func FindMarkPosition(chr rune) int
- func FindVowelPosition(chr rune) int
- func Flatten(composition []*Transformation, mode Mode) string
- func GetCharsetNames() []string
- func GetInputMethodDefinitions() map[string]InputMethodDefinition
- func HasAnyVietnameseRune(word string) bool
- func IsAlpha(c rune) bool
- func IsPunctuationMark(key rune) bool
- func IsVietnameseRune(lowerKey rune) bool
- func IsVowel(chr rune) bool
- func IsWordBreakSymbol(key rune) bool
- type EffectType
- type IEngine
- type InputMethod
- type InputMethodDefinition
- type Mark
- type Mode
- type Rule
- type TelexEngine
- func (e *TelexEngine) CanProcessKey(key rune) bool
- func (e *TelexEngine) GetFlag(flag uint) uint
- func (e *TelexEngine) GetInputMethod() InputMethod
- func (e *TelexEngine) GetProcessedString(mode Mode) string
- func (e *TelexEngine) IsValid(inputIsFullComplete bool) bool
- func (e *TelexEngine) ProcessKey(key rune, mode Mode)
- func (e *TelexEngine) ProcessString(str string, mode Mode)
- func (e *TelexEngine) RemoveLastChar(refreshLastToneTarget bool)
- func (e *TelexEngine) Reset()
- func (e *TelexEngine) RestoreLastWord()
- func (e *TelexEngine) SetFlag(flag uint)
- type Tone
- type Transformation
Constants ¶
View Source
const ( EstdToneStyle uint = 1 << iota EautoCorrectEnabled EstdFlags = EstdToneStyle | EautoCorrectEnabled )
View Source
const UNICODE = "Unicode"
Variables ¶
View Source
var InputMethodDefinitions = map[string]InputMethodDefinition{
"Telex": {
"z": "XoaDauThanh",
"s": "DauSac",
"f": "DauHuyen",
"r": "DauHoi",
"x": "DauNga",
"j": "DauNang",
"a": "A_Â",
"e": "E_Ê",
"o": "O_Ô",
"w": "UOA_ƯƠĂ",
"d": "D_Đ",
},
}
View Source
var PunctuationMarks = []rune{
',', ';', ':', '.', '"', '\'', '!', '?', ' ',
'<', '>', '=', '+', '-', '*', '/', '\\',
'_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']',
'|',
}
View Source
var Vowels = []rune("aàáảãạăằắẳẵặâầấẩẫậeèéẻẽẹêềếểễệiìíỉĩịoòóỏõọôồốổỗộơờớởỡợuùúủũụưừứửữựyỳýỷỹỵ")
Functions ¶
func AddMarkToChar ¶
func AddMarkToTonelessChar ¶
func AddToneToChar ¶
func FindMarkPosition ¶
func FindVowelPosition ¶
func Flatten ¶
func Flatten(composition []*Transformation, mode Mode) string
func GetCharsetNames ¶
func GetCharsetNames() []string
func GetInputMethodDefinitions ¶
func GetInputMethodDefinitions() map[string]InputMethodDefinition
func HasAnyVietnameseRune ¶
func IsPunctuationMark ¶
func IsVietnameseRune ¶
func IsWordBreakSymbol ¶
Types ¶
type EffectType ¶
type EffectType int
const ( Appending EffectType = iota << 0 MarkTransformation EffectType = iota ToneTransformation EffectType = iota Replacing EffectType = iota )
type IEngine ¶
type IEngine interface { SetFlag(uint) GetInputMethod() InputMethod ProcessKey(rune, Mode) ProcessString(string, Mode) GetProcessedString(Mode) string IsValid(bool) bool CanProcessKey(rune) bool RemoveLastChar(bool) RestoreLastWord() Reset() }
func NewEngine ¶
func NewEngine(inputMethod InputMethod, flag uint) IEngine
type InputMethod ¶
type InputMethod struct { Name string Rules []Rule SuperKeys []rune ToneKeys []rune AppendingKeys []rune Keys []rune }
func ParseInputMethod ¶
func ParseInputMethod(imDef map[string]InputMethodDefinition, imName string) InputMethod
type InputMethodDefinition ¶
type Rule ¶
type Rule struct { Key rune Effect uint8 // (Tone, Mark) EffectType EffectType EffectOn rune Result rune AppendedRules []Rule }
func ParseRules ¶
func ParseToneLessRule ¶
func ParseTonelessRules ¶
type TelexEngine ¶
type TelexEngine struct {
// contains filtered or unexported fields
}
func (*TelexEngine) CanProcessKey ¶
func (e *TelexEngine) CanProcessKey(key rune) bool
func (*TelexEngine) GetFlag ¶
func (e *TelexEngine) GetFlag(flag uint) uint
func (*TelexEngine) GetInputMethod ¶
func (e *TelexEngine) GetInputMethod() InputMethod
func (*TelexEngine) GetProcessedString ¶
func (e *TelexEngine) GetProcessedString(mode Mode) string
func (*TelexEngine) IsValid ¶
func (e *TelexEngine) IsValid(inputIsFullComplete bool) bool
func (*TelexEngine) ProcessKey ¶
func (e *TelexEngine) ProcessKey(key rune, mode Mode)
func (*TelexEngine) ProcessString ¶
func (e *TelexEngine) ProcessString(str string, mode Mode)
func (*TelexEngine) RemoveLastChar ¶
func (e *TelexEngine) RemoveLastChar(refreshLastToneTarget bool)
Find the last APPENDING transformation and all the transformations that add effects to it.
func (*TelexEngine) Reset ¶
func (e *TelexEngine) Reset()
func (*TelexEngine) RestoreLastWord ¶
func (e *TelexEngine) RestoreLastWord()
func (*TelexEngine) SetFlag ¶
func (e *TelexEngine) SetFlag(flag uint)
type Transformation ¶
type Transformation struct { Rule Rule Target *Transformation IsUpperCase bool }
Click to show internal directories.
Click to hide internal directories.