Skip to content

Commit

Permalink
Better French book abbreviation handling (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwinston-bn authored Dec 16, 2024
1 parent a74e22a commit adfe69a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,83 +66,89 @@ private static Task<string> SetCorrectBibleBookAbbreviation(string text)
{
text = BibleBookRegex()
.Replace(text,
m => m.Value.ToLower().Replace(NarrowNonBreakingSpace, " ") switch
m =>
{
"gen" or "ge" => "Gn",
"exod" => "Ex",
"lev" or "lév" => "Lv",
"nomb" => "Nb",
"deut" => "Dt",
"josh" => "Jos",
"ju" or "juges" => "Jg",
"ruth" => "Rt",
"1 s" or "1 sa" or "1 sam" => "1S",
"2 s" or "2 sa" or "2 sam" => "2S",
"1 r" or "1 rois" => "1R",
"2 r" or "2 rois" => "2R",
"1 ch" or "1 chr" => "1Ch",
"2 ch" or "2 chr" => "2Ch",
"ezra" or "esdras" => "Esd",
"neh" or "néh" => "Né",
"job" => "Jb",
"psa" or "pss" => "Ps",
"prov" or "pro" or "prv" => "Pr",
"ecc" => "Ec",
"sg" => "Ct",
"is" or "isa" or "és" => "Es",
"jer" or "jér" => "Jr",
"lam" => "Lm",
"éz" => "Ez",
"da" or "dan" => "Dn",
"hos" => "Os",
"joel" or "joël" or "joe" => "Jl",
"amos" => "Am",
"ob" => "Ab",
"jonah" or "jonas" => "Jon",
"mic" => "Mi",
"nah" => "Na",
"hab" => "Ha",
"zeph" or "soph" => "So",
"hag" => "Ag",
"zech" or "zach" or "zec" or "zac" => "Za",
"mal" => "Ml",
"matt" => "Mt",
"mk" or "marc" => "Mc",
"tob" => "Tb",
"1 macc" => "1\u202fM",
"2 macc" => "2\u202fM",
"sa" => "Sg",
"sir" => "Si",
"bar" => "Ba",
"lk" or "luc" => "Lc",
"jean" or "john" => "Jn",
"acts" or "actes" => "Ac",
"ro" or "rom" => "Rm",
"1 c" or "1 co" or "1 cor" => "1Co",
"2 c" or "2 co" or "2 cor" => "2Co",
"gal" => "Ga",
"éph" or "eph" or "ép" => "Ep",
"phil" => "Ph",
"1 th" or "1 the" or "1 thess" => "1Th",
"2 th" or "2 the" or "2 thess" => "2Th",
"1 ti" or "1 tm" or "1 tim" => "1Tm",
"2 ti" or "2 tm" or "2 tim" => "2Tm",
"tite" => "Ti",
"heb" or "héb" => "Hé",
"james" or "ja" or "jac" => "Jc",
"1 p" or "1 pi" or "1 pe" => "1P",
"2 p" or "2 pi" or "2 pe" => "2P",
"1 j" or "1 jn" => "1Jn",
"2 j" or "2 jn" => "2Jn",
"3 j" or "3 jn" => "3Jn",
"jud" or "ju" => "Jd",
"re" or "rév" or "rev" => "Ap",
_ => m.Value
var correctedValue = m.Value.Trim().Replace(".", "");
correctedValue = correctedValue.ToLower().Replace(NarrowNonBreakingSpace, " ") switch
{
"gen" or "ge" => "Gn",
"exod" => "Ex",
"lev" or "lév" => "Lv",
"nomb" => "Nb",
"deut" => "Dt",
"josh" => "Jos",
"ju" or "juges" => "Jg",
"ruth" => "Rt",
"1 s" or "1 sa" or "1 sam" => "1S",
"2 s" or "2 sa" or "2 sam" => "2S",
"1 r" or "1 rois" => "1R",
"2 r" or "2 rois" => "2R",
"1 ch" or "1 chr" => "1Ch",
"2 ch" or "2 chr" => "2Ch",
"ezra" or "esdras" => "Esd",
"neh" or "néh" => "Né",
"job" => "Jb",
"psa" or "pss" => "Ps",
"prov" or "pro" or "prv" => "Pr",
"ecc" => "Ec",
"sg" => "Ct",
"is" or "isa" or "és" => "Es",
"jer" or "jér" => "Jr",
"lam" => "Lm",
"éz" => "Ez",
"da" or "dan" => "Dn",
"hos" => "Os",
"joel" or "joël" or "joe" => "Jl",
"amos" => "Am",
"ob" => "Ab",
"jonah" or "jonas" => "Jon",
"mic" => "Mi",
"nah" => "Na",
"hab" => "Ha",
"zeph" or "soph" => "So",
"hag" => "Ag",
"zech" or "zach" or "zec" or "zac" => "Za",
"mal" => "Ml",
"matt" => "Mt",
"mk" or "marc" => "Mc",
"tob" => "Tb",
"1 macc" => $"1{NarrowNonBreakingSpace}M",
"2 macc" => $"2{NarrowNonBreakingSpace}M",
"sa" => "Sg",
"sir" => "Si",
"bar" => "Ba",
"lk" or "luc" => "Lc",
"jean" or "john" => "Jn",
"acts" or "actes" => "Ac",
"ro" or "rom" => "Rm",
"1 c" or "1 co" or "1 cor" => "1Co",
"2 c" or "2 co" or "2 cor" => "2Co",
"gal" => "Ga",
"éph" or "eph" or "ép" => "Ep",
"phil" => "Ph",
"1 th" or "1 the" or "1 thess" => "1Th",
"2 th" or "2 the" or "2 thess" => "2Th",
"1 ti" or "1 tm" or "1 tim" => "1Tm",
"2 ti" or "2 tm" or "2 tim" => "2Tm",
"tite" => "Ti",
"heb" or "héb" => "Hé",
"james" or "ja" or "jac" => "Jc",
"1 p" or "1 pi" or "1 pe" => "1P",
"2 p" or "2 pi" or "2 pe" => "2P",
"1 j" or "1 jn" => "1Jn",
"2 j" or "2 jn" => "2Jn",
"3 j" or "3 jn" => "3Jn",
"jud" or "ju" => "Jd",
"re" or "rév" or "rev" => "Ap",
_ => correctedValue
};

return correctedValue + " ";
});

return Task.FromResult(text);
}

[GeneratedRegex(@"(?:\d+[^\S\r\n])?([a-zA-Zà-üÀ-Ü]+)(?=[^\S\r\n|\.]\d+)")]
[GeneratedRegex(@"(?:\d+[^\S\r\n])?([a-zA-Zà-üÀ-Ü]+\.?[^\S\r\n]?)(?=[^\S\r\n]?\d+)")]
private static partial Regex BibleBookRegex();
}
Loading

0 comments on commit adfe69a

Please sign in to comment.