Preserve Arabic spelling choices
This commit is contained in:
@@ -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)])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user