varnamproject / govarnam

Easily type Indic languages on computer and mobile. GoVarnam is a cross-platform transliteration library. Manglish -> Malayalam, Thanglish -> Tamil, Hinglish -> Hindi plus another 10 languages. GoVarnam is a near-Go port of libvarnam
https://varnamproject.com
Other
145 stars 11 forks source link

Improve search symbol table #19

Closed subins2000 closed 2 years ago

subins2000 commented 2 years ago

Symbol table search had a fatal flaw :

var searchCriteria Symbol
searchCriteria.Pattern = "a"
searchCriteria.AcceptCondition = 0

Varnam omitted a search criteria by seeing if the value is a default struct value of Go. Go's default struct value is 0 which means one can't apply a search criteria of value 0. The solution applied in this PR to this is to set default value -1 by calling func NewSymbol(): Symbol. So now:

searchCriteria := NewSymbol()
searchCriteria.Pattern = "a"
searchCriteria.AcceptCondition = 0
subins2000 commented 2 years ago

Ignoring test failure cause it depends on https://github.com/varnamproject/schemes/pull/4 which depends on this PR :D