Skip to content

Commit aa5022c

Browse files
committed
Fix breaking of character when a partial word from dictionary
is combined to input having native language words, bugfix after #53
1 parent 8f08330 commit aa5022c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

govarnam/channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (varnam *Varnam) channelGetFromDictionary(ctx context.Context, word string,
128128

129129
if len(dictResult.partialMatches) > 0 {
130130
// Tokenize the word after the longest match found in dictionary
131-
restOfWord := word[dictResult.longestMatchPosition+1:]
131+
restOfWord := string([]rune(word)[dictResult.longestMatchPosition+1:])
132132

133133
start := time.Now()
134134

govarnam/govarnam_ml_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,5 @@ func TestMLNativePartialWordsInInput(t *testing.T) {
507507

508508
assertEqual(t, varnam.TransliterateAdvanced("ആലppu").DictionarySuggestions[0].Word, "ആലപ്പുഴ")
509509
assertEqual(t, varnam.TransliterateAdvanced("puസ്ത").DictionarySuggestions[0].Word, "പുസ്തകം")
510+
assertEqual(t, varnam.TransliterateAdvanced("ആലippazham").DictionarySuggestions[0].Word, "ആലിപ്പഴം")
510511
}

0 commit comments

Comments
 (0)