moved check to a function

This commit is contained in:
Miodec 2022-07-11 22:29:35 +02:00
parent e1cc4716b8
commit f630091152

View file

@ -70,6 +70,10 @@ export function setNotSignedInUid(uid: string): void {
notSignedInLastResult.hash = objectHash(notSignedInLastResult);
}
function shouldCapitalize(lastChar: string): boolean {
return /[?!.؟]/.test(lastChar);
}
let spanishSentenceTracker = "";
export async function punctuateWord(
previousWord: string,
@ -106,8 +110,8 @@ export async function punctuateWord(
}
} else {
if (
(index == 0 || lastChar == "." || lastChar == "?" || lastChar == "!") &&
currentLanguage != "code"
currentLanguage != "code" &&
(index == 0 || shouldCapitalize(lastChar))
) {
//always capitalise the first word or if there was a dot unless using a code alphabet