Documentation ¶
Overview ¶
Package bamboo 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 HasAnyVietnameseVower(word string) bool
- func IsAlpha(c rune) bool
- func IsPunctuationMark(key rune) bool
- func IsSpace(key rune) bool
- func IsVietnameseRune(lowerKey rune) bool
- func IsVowel(chr rune) bool
- func IsWordBreakSymbol(key rune) bool
- type BambooEngine
- func (e *BambooEngine) CanProcessKey(key rune) bool
- func (e *BambooEngine) GetFlag(flag uint) uint
- func (e *BambooEngine) GetInputMethod() InputMethod
- func (e *BambooEngine) GetProcessedString(mode Mode) string
- func (e *BambooEngine) IsValid(inputIsFullComplete bool) bool
- func (e *BambooEngine) ProcessKey(key rune, mode Mode)
- func (e *BambooEngine) ProcessString(str string, mode Mode)
- func (e *BambooEngine) RemoveLastChar(refreshLastToneTarget bool)
- func (e *BambooEngine) Reset()
- func (e *BambooEngine) RestoreLastWord(toVietnamese bool)
- func (e *BambooEngine) SetFlag(flag uint)
- type EffectType
- type IEngine
- type InputMethod
- type InputMethodDefinition
- type Mark
- type Mode
- type Rule
- type Tone
- type Transformation
Constants ¶
View Source
const ( EfreeToneMarking uint = 1 << iota EstdToneStyle EautoCorrectEnabled EstdFlags = EfreeToneMarking | 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_Đ",
},
"VNI": {
"0": "XoaDauThanh",
"1": "DauSac",
"2": "DauHuyen",
"3": "DauHoi",
"4": "DauNga",
"5": "DauNang",
"6": "AEO_ÂÊÔ",
"7": "UO_ƯƠ",
"8": "A_Ă",
"9": "D_Đ",
},
"VIQR": {
"0": "XoaDauThanh",
"'": "DauSac",
"`": "DauHuyen",
"?": "DauHoi",
"~": "DauNga",
".": "DauNang",
"^": "AEO_ÂÊÔ",
"+": "UO_ƯƠ",
"*": "UO_ƯƠ",
"(": "A_Ă",
"\\": "D_Đ",
},
"Microsoft layout": {
"8": "DauSac",
"5": "DauHuyen",
"6": "DauHoi",
"7": "DauNga",
"9": "DauNang",
"1": "__ă",
"!": "_Ă",
"2": "__â",
"@": "_Â",
"3": "__ê",
"#": "_Ê",
"4": "__ô",
"$": "_Ô",
"0": "__đ",
")": "_Đ",
"[": "__ư",
"{": "_Ư",
"]": "__ơ",
"}": "_Ơ",
},
"Telex 2": {
"z": "XoaDauThanh",
"s": "DauSac",
"f": "DauHuyen",
"r": "DauHoi",
"x": "DauNga",
"j": "DauNang",
"a": "A_Â",
"e": "E_Ê",
"o": "O_Ô",
"w": "UOA_ƯƠĂ__Ư",
"d": "D_Đ",
"]": "__ư",
"[": "__ơ",
"}": "_Ư",
"{": "_Ơ",
},
"Telex + VNI": {
"z": "XoaDauThanh",
"s": "DauSac",
"f": "DauHuyen",
"r": "DauHoi",
"x": "DauNga",
"j": "DauNang",
"a": "A_Â",
"e": "E_Ê",
"o": "O_Ô",
"w": "UOA_ƯƠĂ",
"d": "D_Đ",
"0": "XoaDauThanh",
"1": "DauSac",
"2": "DauHuyen",
"3": "DauHoi",
"4": "DauNga",
"5": "DauNang",
"6": "AEO_ÂÊÔ",
"7": "UO_ƯƠ",
"8": "A_Ă",
"9": "D_Đ",
},
"Telex + VNI + VIQR": {
"z": "XoaDauThanh",
"s": "DauSac",
"f": "DauHuyen",
"r": "DauHoi",
"x": "DauNga",
"j": "DauNang",
"a": "A_Â",
"e": "E_Ê",
"o": "O_Ô",
"w": "UOA_ƯƠĂ",
"d": "D_Đ",
"0": "XoaDauThanh",
"1": "DauSac",
"2": "DauHuyen",
"3": "DauHoi",
"4": "DauNga",
"5": "DauNang",
"6": "AEO_ÂÊÔ",
"7": "UO_ƯƠ",
"8": "A_Ă",
"9": "D_Đ",
"'": "DauSac",
"`": "DauHuyen",
"?": "DauHoi",
"~": "DauNga",
".": "DauNang",
"^": "AEO_ÂÊÔ",
"+": "UO_ƯƠ",
"*": "UO_ƯƠ",
"(": "A_Ă",
"\\": "D_Đ",
},
"VNI Bàn phím tiếng Pháp": {
"&": "XoaDauThanh",
"é": "DauSac",
"\"": "DauHuyen",
"'": "DauHoi",
"(": "DauNga",
"-": "DauNang",
"è": "AEO_ÂÊÔ",
"_": "UO_ƯƠ",
"ç": "A_Ă",
"à": "D_Đ",
},
"Telex W": {
"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 ¶ added in v0.5.9
func AddToneToChar ¶
func FindMarkPosition ¶
func FindVowelPosition ¶
func Flatten ¶
func Flatten(composition []*Transformation, mode Mode) string
func GetCharsetNames ¶
func GetCharsetNames() []string
func GetInputMethodDefinitions ¶ added in v0.5.9
func GetInputMethodDefinitions() map[string]InputMethodDefinition
func HasAnyVietnameseRune ¶ added in v0.5.5
func HasAnyVietnameseVower ¶
func IsPunctuationMark ¶ added in v0.5.9
func IsVietnameseRune ¶ added in v0.5.9
func IsWordBreakSymbol ¶ added in v0.3.4
Types ¶
type BambooEngine ¶
type BambooEngine struct {
// contains filtered or unexported fields
}
func (*BambooEngine) CanProcessKey ¶ added in v0.3.4
func (e *BambooEngine) CanProcessKey(key rune) bool
func (*BambooEngine) GetFlag ¶
func (e *BambooEngine) GetFlag(flag uint) uint
func (*BambooEngine) GetInputMethod ¶
func (e *BambooEngine) GetInputMethod() InputMethod
func (*BambooEngine) GetProcessedString ¶
func (e *BambooEngine) GetProcessedString(mode Mode) string
func (*BambooEngine) IsValid ¶ added in v0.5.9
func (e *BambooEngine) IsValid(inputIsFullComplete bool) bool
func (*BambooEngine) ProcessKey ¶ added in v0.3.4
func (e *BambooEngine) ProcessKey(key rune, mode Mode)
func (*BambooEngine) ProcessString ¶
func (e *BambooEngine) ProcessString(str string, mode Mode)
func (*BambooEngine) RemoveLastChar ¶
func (e *BambooEngine) RemoveLastChar(refreshLastToneTarget bool)
Find the last APPENDING transformation and all the transformations that add effects to it.
func (*BambooEngine) Reset ¶
func (e *BambooEngine) Reset()
func (*BambooEngine) RestoreLastWord ¶ added in v0.4.8
func (e *BambooEngine) RestoreLastWord(toVietnamese bool)
func (*BambooEngine) SetFlag ¶
func (e *BambooEngine) SetFlag(flag uint)
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(bool) 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 ¶ added in v0.3.4
func ParseInputMethod(imDef map[string]InputMethodDefinition, imName string) InputMethod
type InputMethodDefinition ¶ added in v0.3.4
type Rule ¶
type Rule struct { Key rune Effect uint8 // (Tone, Mark) EffectType EffectType EffectOn rune Result rune AppendedRules []Rule }
func ParseRules ¶
func ParseToneLessRule ¶ added in v0.4.9
func ParseTonelessRules ¶
type Transformation ¶
type Transformation struct { Rule Rule Target *Transformation IsUpperCase bool }
Click to show internal directories.
Click to hide internal directories.