Skip to content

Commit 46122bf

Browse files
authored
Merge branch 'main' into main
2 parents 64bf525 + a0dfa99 commit 46122bf

File tree

16 files changed

+250
-248
lines changed

16 files changed

+250
-248
lines changed

Cargo.lock

Lines changed: 40 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/braillify/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ readme = "../../README.md"
1313
homepage = "https://braillify.kr"
1414

1515
[dependencies]
16-
phf = { version = "0.11", features = ["macros"] }
16+
phf = { version = "0.12", features = ["macros"] }
1717

1818

1919
[dev-dependencies]
20-
csv = "1.3.0"
20+
csv = "1.3.1"
2121
serde_json = "^1"
2222
proptest = "1.7"

libs/braillify/src/char_struct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct KoreanChar {
1414
impl KoreanChar {
1515
pub fn new(c: char) -> Result<Self, String> {
1616
let code = c as u32;
17-
if !(0xAC00 <= code && code <= 0xD7A3) {
17+
if !(0xAC00..=0xD7A3).contains(&code) {
1818
return Err("Invalid Korean character".to_string());
1919
}
2020

@@ -76,13 +76,13 @@ impl CharType {
7676
return Ok(Self::MathSymbol(c));
7777
}
7878
let code = c as u32;
79-
if 0x3131 <= code && code <= 0x3163 {
79+
if (0x3131..=0x3163).contains(&code) {
8080
return Ok(Self::KoreanPart(c));
8181
}
8282
// if !(0xAC00 <= code && code <= 0xD7A3) {
8383
// return Ok(Self::Char(c));
8484
// }
85-
if 0xAC00 <= code && code <= 0xD7A3 {
85+
if (0xAC00..=0xD7A3).contains(&code) {
8686
return Ok(Self::Korean(KoreanChar::new(c)?));
8787
}
8888
if c.is_whitespace() {

libs/braillify/src/korean_char.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ pub fn encode_korean_char(korean: &KoreanChar) -> Result<Vec<u8>, String> {
5252
result.extend(encode_jungsong(korean.jung)?);
5353
result.extend(encode_jongseong(jong)?);
5454
}
55+
} else if let Ok(code) = char_shortcut::encode_char_shortcut(build_char(cho0, korean.jung, None)) {
56+
result.extend(code);
5557
} else {
56-
if let Ok(code) = char_shortcut::encode_char_shortcut(build_char(cho0, korean.jung, None)) {
57-
result.extend(code);
58-
} else {
59-
// shortcut 이 없으므로 초성 중성, 모두 결합
60-
if cho0 != 'ㅇ' {
61-
result.push(encode_choseong(cho0)?);
62-
}
63-
result.extend(encode_jungsong(korean.jung)?);
58+
// shortcut 이 없으므로 초성 중성, 모두 결합
59+
if cho0 != 'ㅇ' {
60+
result.push(encode_choseong(cho0)?);
6461
}
62+
result.extend(encode_jungsong(korean.jung)?);
6563
}
6664

6765
Ok(result)

libs/braillify/src/lib.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,15 @@ impl Encoder {
210210
// 8항 - 단독으로 쓰인 자모
211211
result.push(63);
212212
result.extend(korean_part::encode_korean_part(c)?);
213+
} else if has_korean_char {
214+
// 10항 - 단독으로 쓰인 자음자가 단어에 붙어 나올 때
215+
result.push(56);
216+
result.extend(korean_part::encode_korean_part(c)?);
213217
} else {
214-
if has_korean_char {
215-
// 10항 - 단독으로 쓰인 자음자가 단어에 붙어 나올 때
216-
result.push(56);
217-
result.extend(korean_part::encode_korean_part(c)?);
218-
} else {
219-
// 10항 - 단독으로 쓰인 자음자가 단어에 붙어 나올 때
220-
// 8항 - 단독으로 쓰인 자모
221-
result.push(63);
222-
result.extend(korean_part::encode_korean_part(c)?);
223-
}
218+
// 10항 - 단독으로 쓰인 자음자가 단어에 붙어 나올 때
219+
// 8항 - 단독으로 쓰인 자모
220+
result.push(63);
221+
result.extend(korean_part::encode_korean_part(c)?);
224222
}
225223
}
226224
}
@@ -337,8 +335,8 @@ impl Encoder {
337335
}
338336
}
339337

340-
if self.triple_big_english {
341-
if !(remaining_words
338+
if self.triple_big_english
339+
&& !(remaining_words
342340
.first()
343341
.is_some_and(|w| w.chars().all(|c| c.is_ascii_alphabetic())))
344342
{
@@ -349,7 +347,6 @@ impl Encoder {
349347
result.push(4);
350348
self.triple_big_english = false; // Reset after adding terminator
351349
}
352-
}
353350
if !remaining_words.is_empty() {
354351
if self.english_indicator
355352
&& !remaining_words[0]
@@ -590,7 +587,8 @@ mod test {
590587
for (line_num, result) in reader.into_records().enumerate() {
591588
total += 1;
592589
file_total += 1;
593-
let record = result.unwrap();
590+
let error = format!("CSV 레코드를 읽는 중 오류 발생: {:?} at {}", result, line_num);
591+
let record = result.expect(&error);
594592
let input = &record[0];
595593
let expected = record[2].replace(" ", "⠀");
596594
match encode(input) {

0 commit comments

Comments
 (0)