Skip to content

Commit

Permalink
Fix #5, type അല്പംeasily
Browse files Browse the repository at this point in the history
  • Loading branch information
subins2000 committed Mar 6, 2022
1 parent ffde8ee commit b427d66
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
10 changes: 9 additions & 1 deletion schemes/ml/ml.scheme
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ consonants ["ka"] => "ക",
["pha", "fa", "Fa"] => "ഫ",
"ba" => "ബ",
"bha" => "ഭ",
"la" => "ല",
["va", "wa"] => "വ",
["Sa", ["sha", "sa"]] => "ശ",
["sa", "za"] => "സ",
Expand Down Expand Up @@ -160,7 +161,6 @@ consonants ["ra"] => "ര",
[["ra"], "Ra"] => "റ",
["na"] => "ന",
[["na"], "Na"] => "ണ",
["la"] => "ല",
[["la"], "La"] => "ള"

infer_dead_consonants true
Expand Down Expand Up @@ -197,6 +197,14 @@ delete_token(
)
consonants({:accept_if => :starts_with}, "m" => "മ്")

{"l" => "ല"}.each do |key, value|
value_with_anusvara = "#{value}്"
delete_token(
value1: value_with_anusvara
)
consonants({:accept_if => :in_between}, key => value_with_anusvara)
end

consonants [["ru"]] => "ര്",
[["r~", "ru"]] => "റ്",
[["nu"]] => "ന്",
Expand Down
51 changes: 36 additions & 15 deletions test/ml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ def setup
@varnam.config(Varnam::VARNAM_CONFIG_SET_TOKENIZER_SUGGESTIONS_LIMIT, 30)
end

def test_words
list = {
def test_basic_words
# TODO assert length of result array too
assert_hash_transliterate({
'peN' => 'പെൺ',
'kiLivaathil' => 'കിളിവാതിൽ',
'kiLivaathilil' => 'കിളിവാതിലിൽ',
'thaazhvara' => 'താഴ്വര',
'thaazh_vara' => 'താഴ്‌വര',
'ANkiLi' => 'ആൺകിളി'
})
end

# BEGIN Anusvara <-> ma complications
def test_anusvara_ma_complications
assert_hash_transliterate({
'am_bEdkar' => 'അംബേദ്കർ',
'manam_pOle' => 'മനംപോലെ',
'kunnamkuLam' => 'കുന്നംകുളം',
Expand All @@ -19,19 +28,25 @@ def test_words
'mvOnE' => 'മ്വോനേ',
'mvOnoossE' => 'മ്വോനൂസ്സേ',
'manushyan' => 'മനുഷ്യൻ',
'mlEchcham' => 'മ്ലേച്ചം',
# END Anusvara <-> ma complications
'mlEchcham' => 'മ്ലേച്ചം'
})
end

'kiLivaathil' => 'കിളിവാതിൽ',
'kiLivaathilil' => 'കിളിവാതിലിൽ',
'thaazhvara' => 'താഴ്വര',
'thaazh_vara' => 'താഴ്‌വര',
'ANkiLi' => 'ആൺകിളി'
}
list.each do |pattern, expected|
# TODO assert length of result array too
assert_equal expected, @varnam.transliterate(pattern)[0].Word
end
def test_chil_and_words
assert_hash_transliterate({
'alpam' => 'അല്പം',
'l' => 'ൽ',
'lakkiTi' => 'ലക്കിടി',
'kuyil' => 'കുയിൽ'
})

assert_hash_transliterate({
'aaScharyam' => 'ആശ്ചര്യം',
'r' => 'ർ',
'raakkiLi' => 'രാക്കിളി',
'payar' => 'പയർ',
'ervin' => 'എര്വിൻ'
})
end

def test_reverse_transliteration
Expand All @@ -43,4 +58,10 @@ def test_reverse_transliteration
assert_equal expected, @varnam.reverse_transliterate(word)
end
end

def assert_hash_transliterate(list)
list.each do |pattern, expected|
assert_equal expected, @varnam.transliterate(pattern)[0].Word
end
end
end

0 comments on commit b427d66

Please sign in to comment.