WikiFunctions.Parse.TypoGroup.FixTypo C# (CSharp) Метод

FixTypo() приватный Метод

Applies a given typo fix to the article, provided the typo does not also match the article title Updates edit summary based on the first match (value and replacement) of the typo and the total number of replacements
private FixTypo ( string &articleText, string &summary, string>.KeyValuePair typo, string articleTitle ) : void
articleText string The wiki text of the article.
summary string
typo string>.KeyValuePair
articleTitle string Title of the article
Результат void
        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);
            }
        }