private void FixTypo(ref string articleText, ref string summary, KeyValuePair<Regex, string> typo, string articleTitle)
{
// don't apply the typo if it matches on the Article's title
if (typo.Key.IsMatch(articleTitle))
return;
string comma = @", ";
if (Variables.LangCode.Equals("ar") || Variables.LangCode.Equals("arz") || Variables.LangCode.Equals("fa"))
comma = @"، ";
MatchCollection matches = typo.Key.Matches(articleText);
if (matches.Count > 0)
{
TypoStat stats = new TypoStat(typo) { Total = matches.Count };
articleText = typo.Key.Replace(articleText, typo.Value);
int count = 0;
foreach (Match m in matches)
{
string res = m.Result(typo.Value);
if (res != m.Value)
{
count++;
if (1 == count)
summary += (summary.Length > 0 ? comma : "") + m.Value + FindandReplace.Arrow + res;
}
}
if (count > 1)
summary += " (" + count + ")";
stats.SelfMatches = stats.Total - count;
Statistics.Add(stats);
}
}