From b53b0beee617276892003d365eaf2024bca5d1c9 Mon Sep 17 00:00:00 2001 From: Bill D Date: Fri, 28 May 2021 16:28:59 +0430 Subject: [PATCH] more work on ain stuff --- src/lib/diacritics.test.ts | 11 ++++++++--- src/lib/diacritics.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lib/diacritics.test.ts b/src/lib/diacritics.test.ts index 9117fdd..7bab3db 100644 --- a/src/lib/diacritics.test.ts +++ b/src/lib/diacritics.test.ts @@ -516,8 +516,7 @@ const diacriticsSections: { p: "بعد", f: "bad", }, - // TODO: Should this really be an error? - out: null, + out: "بَعد", }, { in: { @@ -547,6 +546,13 @@ const diacriticsSections: { }, out: "مَنْبِعِ", }, + { + in: { + p: "منبع", + f: "manbi", + }, + out: "مَنْبِع" + }, { in: { p: "معنا", @@ -561,7 +567,6 @@ const diacriticsSections: { }, out: "مَعَنا", }, - // TODO: Should be allowed to use a short vowel as well // طمع - tama // استعمال - istimaal // TODO: Starting like عام اعتصاب etc. // { diff --git a/src/lib/diacritics.ts b/src/lib/diacritics.ts index 95148c9..98c68f1 100644 --- a/src/lib/diacritics.ts +++ b/src/lib/diacritics.ts @@ -67,6 +67,7 @@ enum PhonemeStatus { HaEndingWithHeem, AlefDaggarEnding, LongAinVowelMissingComma, + ShortAinVowelMissingComma, } function processPhoneme( @@ -174,6 +175,11 @@ function processPhoneme( advanceP, addP(diacritic) )(state) + : (phs === PhonemeStatus.ShortAinVowelMissingComma) ? + pipe( + addP(diacritic), + advanceP, + )(state) : // phs === PhonemeState.ShortVowel pipe( @@ -198,6 +204,7 @@ function stateInfo({ state, i, phonemes, phoneme }: { const isBeginningOfWord = state.pOut === "" || prevPLetter === " "; const isEndOfWord = !nextPLetter || nextPLetter === " "; const phonemeInfo = phonemeTable[phoneme]; + const nextPhoneme = phonemes[i+1]; const previousPhoneme = i > 0 && phonemes[i-1]; const previousPhonemeInfo = (!isBeginningOfWord && i > 0) && phonemeTable[phonemes[i-1]]; // const nextPhoneme = (phonemes.length > (i + 1)) && phonemes[i+1]; @@ -238,6 +245,9 @@ function stateInfo({ state, i, phonemes, phoneme }: { if (phoneme === "-i-" && isBeginningOfWord) { return PhonemeStatus.Izafe; } + if (currentPLetter === "ع" && phoneme !== "'" && nextPhoneme !== "'" && phonemeInfo.diacritic && !phonemeInfo.longVowel) { + return PhonemeStatus.ShortAinVowelMissingComma; + } if (useAinBlendDiacritics) { return PhonemeStatus.LongAinVowelMissingComma; }