Preserve Arabic spelling choices

This commit is contained in:
diyaa
2026-09-13 22:33:57 +02:00
parent f5ab97e6a0
commit 3865f77dc0
4 changed files with 144 additions and 3 deletions
@@ -64,4 +64,43 @@ final class ArabicPronunciationProcessorTests: XCTestCase {
[.fullTashkeelNeedsReview, .tanweenAdditionNeedsReview]
)
}
func testPreservedSpellingsKeepTheirTanweenWhileOtherTextIsProcessed() {
let protectedSpelling = "\u{0647}\u{064F}\u{062F}\u{064B}\u{0649}"
let otherText = "\u{0634}\u{064F}\u{0643}\u{0652}\u{0631}\u{064B}\u{0627}"
let lyrics = "\(protectedSpelling) \(otherText) \(protectedSpelling)"
let result = processor.process(
lyrics: lyrics,
settings: ArabicPronunciationSettings(
isEnabled: true,
diacritizationPolicy: .pronunciationTargeted,
tanweenPolicy: .removeWhenUnwanted,
preservedSpellings: [protectedSpelling]
)
)
XCTAssertEqual(
result.text,
"\(protectedSpelling) \u{0634}\u{064F}\u{0643}\u{0652}\u{0631}\u{0627} \(protectedSpelling)"
)
XCTAssertEqual(result.notes, [.preservedSpellingsProtected(count: 2)])
}
func testPreservedSpellingsKeepTheirOriginalDiacriticOrder() {
let preservedSpelling = "\u{0645}\u{0651}\u{064E}"
let otherText = "\u{0628}\u{0651}\u{064E}"
let result = processor.process(
lyrics: "\(preservedSpelling) \(otherText)",
settings: ArabicPronunciationSettings(
isEnabled: true,
diacritizationPolicy: .pronunciationTargeted,
preservedSpellings: [preservedSpelling]
)
)
XCTAssertEqual(result.text, "\(preservedSpelling) \u{0628}\u{064E}\u{0651}")
XCTAssertEqual(result.notes, [.preservedSpellingsProtected(count: 1)])
}
}