Represents statistics for one typo rule
        private void FixTypo(ref string ArticleText, ref string summary, KeyValuePair <Regex, string> typo)
        {
            MatchCollection matches = typo.Key.Matches(ArticleText);

            if (matches.Count > 0)
            {
                TypoStat stats = new TypoStat(typo);
                stats.Total = matches.Count;
                ArticleText = typo.Key.Replace(ArticleText, typo.Value);
                int count = 0;

                foreach (Match m in matches)
                {
                    string res = typo.Key.Replace(m.Value, typo.Value);
                    if (res != m.Value)
                    {
                        count++;
                        if (1 == count)
                        {
                            summary += (summary.Length > 0 ? ", " : "") + m.Value + FindandReplace.Arrow + res;
                        }
                    }
                }
                if (count > 1)
                {
                    summary += " (" + count.ToString() + ")";
                }
                stats.SelfMatches = stats.Total - count;
                Statistics.Add(stats);
            }
        }
        public override bool Equals(object obj)
        {
            TypoStat item = (obj as TypoStat);

            if (item == null)
            {
                return(false);
            }

            return((item.Find == Find) && (item.Replace == Replace));
        }
        /// <summary>
        /// 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 & replacement) of the typo and the total number of replacements
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="summary"></param>
        /// <param name="typo"></param>
        /// <param name="articleTitle">Title of the article</param>
        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);
            }
        }
        /// <summary>
        /// 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 & replacement) of the typo and the total number of replacements
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="summary"></param>
        /// <param name="typo"></param>
        /// <param name="articleTitle">Title of the article</param>
        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);
            }
        }
 public TypoStatsListViewItem(TypoStat stat)
     : base(new[] {stat.Find, stat.Replace, "", ""})
 {
     Typo = stat;
     Typo.ListViewItem = this;
     Refresh();
 }
        private void FixTypo(ref string ArticleText, ref string summary, KeyValuePair<Regex, string> typo)
        {
            MatchCollection matches = typo.Key.Matches(ArticleText);
            if (matches.Count > 0)
            {
                TypoStat stats = new TypoStat(typo);
                stats.Total = matches.Count;
                ArticleText = typo.Key.Replace(ArticleText, typo.Value);
                int count = 0;

                foreach (Match m in matches)
                {
                    string res = typo.Key.Replace(m.Value, typo.Value);
                    if (res != m.Value)
                    {
                        count++;
                        if (1 == count) summary += (summary.Length > 0 ? ", " : "") + m.Value + FindandReplace.Arrow + res;
                    }
                }
                if (count > 1) summary += " (" + count.ToString() + ")";
                stats.SelfMatches = stats.Total - count;
                Statistics.Add(stats);
            }
        }