Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion libs/braillify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,25 @@ impl Encoder {
// 제41항 숫자 사이에 붙어 나오는 쉼표와 자릿점은 ⠂으로 적는다.
result.push(2);
} else {
result.extend(symbol_shortcut::encode_char_symbol_shortcut(c)?);
// 제58항 빠짐표가 여러 개 붙어 나올 때에는 _과 l 사이에 7을 묵자의 개수만큼적어 나타낸다.
if c == '□' {
let mut count = 0;
for wc in word_chars[i..].iter() {
if *wc == '□' {
count += 1;
} else {
break;
}
}
result.push(56);
for _ in 0..count {
result.push(54);
}
result.push(7);
*skip_count = count - 1;
} else {
result.extend(symbol_shortcut::encode_char_symbol_shortcut(c)?);
}
}
}
CharType::Space(c) => {
Expand Down
8 changes: 7 additions & 1 deletion libs/braillify/src/symbol_shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ static SHORTCUT_MAP: phf::Map<char, &'static [u8]> = phf_map! {
'〉' => &[decode_unicode('⠶'), decode_unicode('⠂')],
'《' => &[decode_unicode('⠰'), decode_unicode('⠶')],
'》' => &[decode_unicode('⠶'), decode_unicode('⠆')],
'―' => &[decode_unicode('⠤'), decode_unicode('⠤')],
'-' => &[decode_unicode('⠤')],
'∼' => &[decode_unicode('⠈'), decode_unicode('⠔')],
'‘' => &[decode_unicode('⠠'), decode_unicode('⠦')],
'’' => &[decode_unicode('⠴'), decode_unicode('⠄')],
'-' => &[decode_unicode('⠤')],
'○' => &[decode_unicode('⠸'),decode_unicode('⠴'), decode_unicode('⠇')],
// '×' => &[decode_unicode('⠸'),decode_unicode('⠭'), decode_unicode('⠇')],
'△' => &[decode_unicode('⠸'),decode_unicode('⠬'), decode_unicode('⠇')],
'□' => &[decode_unicode('⠸'),decode_unicode('⠶'), decode_unicode('⠇')],
};

pub fn encode_char_symbol_shortcut(text: char) -> Result<&'static [u8], String> {
Expand Down
4 changes: 2 additions & 2 deletions test_cases/rule_34.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
문 앞에 “Open”이라고 쓰여 있었다.,"eg`<4n`80,op50o""<@u`,,{:`o/s/`i4",172783550298385232211534522116358378323242498211214128,⠑⠛⠈⠣⠲⠝⠈⠦⠴⠠⠕⠏⠢⠴⠕⠐⠣⠈⠥⠈⠠⠠⠪⠱⠈⠕⠌⠎⠌⠈⠊⠲

"‘ㄱ, ㄷ, ㅂ’은 자음 앞이나 어말에서는 ‘k, t, p’로 적는다.",",8=a""`=9""`=b0'z`.<{5`<4oc`se1n,scz`,80k1`;t1`;p0'""u`.?czi4",32386311686320168633524538403423483550219814172293214953832385252848302848155241637840579531050,⠠⠦⠿⠁⠐⠿⠔⠐⠿⠃⠴⠄⠵⠨⠣⠪⠢⠣⠲⠕⠉⠎⠑⠂⠝⠠⠎⠉⠵⠠⠦⠴⠅⠂⠰⠞⠂⠰⠏⠴⠄⠐⠥⠨⠹⠉⠵⠊⠲
"‘ㄱ, ㄷ, ㅂ’은 자음 앞이나 어말에서는 ‘k, t, p’로 적는다.",",8=a""`=9""`=b0'z`.<{5`<4oc`se1n`,scz`,80k1`;t1`;p0'""u`.?czi4",3238631160632016063352453040354234035502190141722903214953032385252048302048155241637040579531050,⠠⠦⠿⠁⠐⠿⠔⠐⠿⠃⠴⠄⠵⠨⠣⠪⠢⠣⠲⠕⠉⠎⠑⠂⠝⠠⠎⠉⠵⠠⠦⠴⠅⠂⠰⠞⠂⠰⠏⠴⠄⠐⠥⠨⠹⠉⠵⠊⠲

링컨(Lincoln)은 미국의 제16대 대통령이다.,"""o7f)8'0,l9coln,0z`eo@maw`.n`#af`ir`irh=""}oi4",162154116238452327209217293252538172181315884029860111810238102319631659211050,⠐⠕⠶⠋⠾⠦⠄⠴⠠⠇⠔⠉⠕⠇⠝⠠⠴⠵⠑⠕⠈⠍⠁⠺⠈⠨⠝⠈⠼⠁⠋⠈⠊⠗⠈⠊⠗⠓⠿⠐⠻⠕⠊⠲
링컨(Lincoln)은 미국의 제16대 대통령이다.,"""O7F)8'0,L9COLN,0Z EO@MAW .N#AF IR IRH=""]OI4",16215411623845232720921729325253017218131580402960111010230102319631659211050,⠐⠕⠶⠋⠾⠦⠄⠴⠠⠇⠔⠉⠕⠇⠝⠠⠴⠵⠑⠕⠈⠍⠁⠺⠀⠨⠝⠼⠁⠋⠀⠊⠗⠀⠊⠗⠓⠿⠐⠻⠕⠊⠲
64 changes: 32 additions & 32 deletions test_cases/rule_49.csv
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
.,4,50,⠲
"? ",8,38,⠦
"! ",6,22,⠖
", ","""",16,⠐
","""2",166,⠐⠆
": ","""1 ",162,⠐⠂
"/ ",_/ ,5612,⠸⠌
"… , ... ",",,,, 444",5050500160505050,⠲⠲⠲⠀⠐⠀⠲⠲⠲
"" ",8,38,⠦
"" ",0,38,⠦
"' ",",8 ",3238,⠠⠦
"' ",0',3238,⠠⠦
"( ",8' ,384,⠦⠄
") ",",0 ",3252,⠠⠴
"{ ",81,382,⠦⠂
"} ","""0",1652,⠐⠴
"[ ",82,386,⠦⠆
"] ",;0,4852,⠰⠴
"『 ",;8,4838,⠰⠦
"』 ",02,526,⠴⠆
"「 ","""8",1638,⠐⠦
"」 ",01,522,⠴⠂
"《 ",;7,4854,⠰⠶
"》 ",72,546,⠶⠆
"〈 ","""7 ",1654,⠐⠶
"〉 ",71,542,⠶⠂
"― ",-- ,3636,⠤⠤
"- ",- ,36,⠤
"∼ ",@9,8200,⠈⠔
"?",8,38,⠦
"!",6,22,⠖
",","""",16,⠐
"·","""2",166,⠐⠆
":","""1 ",162,⠐⠂
"/",_/ ,5612,⠸⠌
"… , ...",",,,, 444",5050500160505050,⠲⠲⠲⠀⠐⠀⠲⠲⠲
""",8,38,⠦
""",0,38,⠦
"'",",8 ",3238,⠠⠦
"'",0',3238,⠠⠦
"(",8' ,384,⠦⠄
")",",0 ",3252,⠠⠴
"{",81,382,⠦⠂
"}","""0",1652,⠐⠴
"[",82,386,⠦⠆
"]",;0,4852,⠰⠴
"『",;8,4838,⠰⠦
"』",02,526,⠴⠆
"「","""8",1638,⠐⠦
"」",01,522,⠴⠂
"《",;7,4854,⠰⠶
"》",72,546,⠶⠆
"〈","""7 ",1654,⠐⠶
"〉",71,542,⠶⠂
"―",-- ,3636,⠤⠤
"-",- ,36,⠤
"∼",@9,8200,⠈⠔
"""˙, __""",",- -'",32360364,⠠⠤⠀⠤⠄
"○ ",_0l ,565270,⠸⠴⠇
",_xl,33,⠡
"△ ",_+l ,56447,⠸⠬⠇
"□ ",_7l,56547,⠸⠶⠇
"○",_0l,56527,⠸⠴⠇
"×",_xl,33,⠡
"△",_+l ,56447,⠸⠬⠇
"□",_7l,56547,⠸⠶⠇
"젊은이는 나라의 기둥입니다.",".t5zocz`c""<w`@oim7obcoi4",40303453219530916355808211013542139211050,⠨⠞⠢⠵⠕⠉⠵⠉⠐⠣⠺⠈⠕⠊⠍⠶⠕⠃⠉⠕⠊⠲
"이번에 가시면 언제 돌아오세요?","o^)n`$,oe*`).n`iu1<u,n+8",21246229043322117330624029010372353732294438,⠕⠘⠾⠝⠫⠠⠕⠑⠡⠾⠨⠝⠊⠥⠂⠣⠥⠠⠝⠬⠦
"이거 정말 큰일이 났구나!",o@s`.]e1`fzo1o`c/@mc6,218140405917201153212210912813922,⠕⠈⠎⠨⠻⠑⠂⠋⠵⠕⠂⠕⠉⠌⠈⠍⠉⠖
Expand Down
2 changes: 1 addition & 1 deletion test_cases/rule_56.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

서울은 대한민국의 수도이다.,",s&z`irj3eq@maw`;-,miu-2oi4",3214475381023261817318131588483632131037366211050,⠠⠎⠯⠵⠈⠊⠗⠚⠒⠑⠟⠈⠍⠁⠺⠈⠰⠤⠠⠍⠊⠥⠤⠆⠕⠊⠲

최명희 작가는 전라북도 전주 출신입니다.,";ye}jw`.a$cz`""-.)""<~maiu`.)`.m-1`;&,qobcoi4",486117592658840143953816364062163524131103784062840133628484732312139211050,⠰⠽⠑⠻⠚⠺⠨⠁⠫⠉⠵⠐⠤⠨⠾⠐⠣⠘⠍⠁⠊⠥⠈⠨⠾⠈⠨⠍⠤⠂⠰⠯⠠⠟⠕⠃⠉⠕⠊⠲
최명희 작가는 전라북도 전주 출신입니다.,";ye}jw`.a$cz`""-.)""<~maiu`.)`.m-1`;&,qobcoi4",486117592658040143953016364062163524131103704062040133620484732312139211050,⠰⠽⠑⠻⠚⠺⠨⠁⠫⠉⠵⠐⠤⠨⠾⠐⠣⠘⠍⠁⠊⠥⠀⠨⠾⠀⠨⠍⠤⠂⠰⠯⠠⠟⠕⠃⠉⠕⠊⠲

"금액 할인: 15,000원 14,500원",@{5ra`j1q"1`@-#ae1jjjp3-a`#ad1ejjp3,842342318262311628836601172262626151836186012521726261518,⠈⠪⠢⠗⠁⠈⠚⠂⠟⠐⠂⠈⠈⠤⠼⠁⠑⠂⠚⠚⠚⠏⠒⠤⠁⠈⠼⠁⠙⠂⠑⠚⠚⠏⠒
2 changes: 1 addition & 1 deletion test_cases/rule_58.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
훈민정음의 초성 중에서 아음은 □□□의 석 자다.,"jgeq.]{5w`;u,]`.m7n,s`<{5z`_777lw`,?`.i4",2627173140594234588483732598401354293214835423453856545454758832578401050,⠚⠛⠑⠟⠨⠻⠪⠢⠺⠰⠥⠠⠻⠨⠍⠶⠝⠠⠎⠣⠪⠢⠵⠸⠶⠶⠶⠇⠺⠈⠠⠹⠈⠨⠊⠲
훈민정음의 초성 중에서 아음은 □□□의 석 자다.,"jgeq.]{5w`;u,]`.m7n,s`<{5z`_777lw`,?`.i4",2627173140594234580483732590401354293214035423453056545454758032570401050,⠚⠛⠑⠟⠨⠻⠪⠢⠺⠰⠥⠠⠻⠨⠍⠶⠝⠠⠎⠣⠪⠢⠵⠸⠶⠶⠶⠇⠺⠀⠠⠹⠀⠨⠊⠲
Loading