Skip to content
Merged
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: 20 additions & 0 deletions stationapi/src/domain/ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ fn lookup_single(c: char) -> Option<Phoneme> {
'ン' => return Some(Phoneme::MoraicNasal),
'ッ' => return Some(Phoneme::Geminate),
'ー' => return Some(Phoneme::LongVowel),
// 空白(全角・半角)はそのまま透過
' ' | ' ' => return Some(Phoneme::Regular(" ")),
_ => return None,
};
Some(Phoneme::Regular(ipa))
Expand Down Expand Up @@ -588,4 +590,22 @@ mod tests {
// ッキョ → kkʲo (only the base consonant 'k' is geminated, not 'kʲ')
assert_eq!(ipa("ニッキョウ"), "ɲikkʲoː");
}

#[test]
fn test_dokkyo_daigakumae_soka_matsubara() {
// Full-width space between words should be preserved
assert_eq!(
ipa("ドッキョウダイガクマエ ソウカマツバラ"),
"dokkʲoːdaiɡakɯmae soːkamat͡sɯbaɾa"
);
}

#[test]
fn test_dokkyo_daigakumae_soka_matsubara_halfwidth() {
// Half-width (ASCII) space between words should also be accepted
assert_eq!(
ipa("ドッキョウダイガクマエ ソウカマツバラ"),
"dokkʲoːdaiɡakɯmae soːkamat͡sɯbaɾa"
);
}
}