Utilisateur:Erabot/Journaux/20070617

Un article de Wikipédia, l'encyclopédie libre.

[modifier] Changement de catégorie

Début : 17/06/2007 22:55:31
Fin : 17/06/2007 23:00:05
Historique : Special:Contributions/Erabot

Mode : automatique

Outil utilisé : AutoWikiBrowser version 3.9.2.0

Options AWB activées :

  • Apply general fixes
  • Unicodify whole article


Catégorie Enseignant à Sciences Po remplacée par catégorie Enseignant à l'Institut d'études politiques de Paris

Module activé :

public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "";
 
            ArticleText = Regex.Replace(ArticleText,
                @"(?<=\[\[)[ _]*" +
                @"(?:" + Variables.LangCode.ToString().ToLower() + @"[ _]*:[ _]*)?" +
                @"(?:Category|" + Variables.Namespaces[14].Replace(":", "") + @")[ _]*:[ _]*" +
                @"(?=[^\]]+\]\])",
                Variables.Namespaces[14], RegexOptions.IgnoreCase);
            ArticleText = Regex.Replace(ArticleText,
                @"(?<=\[\[" +
                Variables.Namespaces[14] +
                @")\p{Ll}",
                new MatchEvaluator(UpFirstChar));
 
            Match match;
            string key;
            if (!Regex.IsMatch(ArticleText, @"\{\{DEFAULTSORT:[^\}]*\}\}"))
            {
                match = Regex.Match(ArticleText, @"\[\[Catégorie:[^\|\]]+\|((?:[^,\]]+(?=,)|[^\]]{2,})(?:, *[^\]]+)?)\]\]");
                if (!match.Success)
                {
                    key = CleanKey(Tools.MakeHumanCatKey(ArticleTitle));
                }
                else
                {
                    key = CleanKey(match.Groups[1].Value);
                }
 
                ArticleText = Regex.Replace(ArticleText,
                    @"(\[\[Catégorie:[^\]]+\]\].*)",
                    "{{DEFAULTSORT:" + key + "}}\n$1",
                    RegexOptions.Singleline);
 
                ArticleText = Regex.Replace(ArticleText,
                    @"(?<=\[\[Catégorie:[^\|\]]+)\|[^\]]{2,}(?=\]\])",
                    "");
            }
            else
            {
                ArticleText = Regex.Replace(ArticleText,
                    @"(?<=\{\{)[ _]*DEFAULTSORT[ _]*:[ _]*([^\}]*?)[ _]*(?=\}\})",
                    new MatchEvaluator(Key),
                    RegexOptions.IgnoreCase);
                ArticleText = Regex.Replace(ArticleText,
                    @"(?<=\{\{DEFAULTSORT:[^\}]*\}\})\s*(?=\[\[" +
                    Variables.Namespaces[14] +
                    @")",
                    "\r\n",
                    RegexOptions.Singleline);
            }
 
            return ArticleText;
        }
 
        private string UpFirstChar(Match m)
        {
            return m.Value.ToUpper();
        }
 
        private string CleanKey(string key)
        {
            key = Regex.Replace(key.Replace("_"," "), @" +", " ");
 
            string[] tr1 = new string[48] { "0⅛¼⅜⅝⅞½¾٠۰", "1١۱", "2٢۲", "3٣۳", "4٤۴", "5٥۵", "6٦۶", "7٧۷", "8٨۸", "9٩۹", "aáàâãäåăąā", "AÁÀÂÃÄÅĂĄĀ", "cçćĉčċ", "CÇĆĈČĊ", "dðďđ", "DÐĎĐ", "eéèêëěėęē", "EÉÈÊËĚĖĘĒ", "gğĝġģ", "GĞĜĠĢ", "hĥħ", "HĤĦ", "iíìîïıĩįī", "IÍÌÎÏİĨĮĪ", "jĵ", "JĴ", "kĸķ", "KĶ", "lĺľłļŀ", "LĹĽŁĻĿ", "nñʼnńňņ", "NÑŃŇŅ", "oóòôõöøőō", "OÓÒÔÕÖØŐŌ", "rŕřŗ", "RŔŘŖ", "sśŝšş", "SŚŜŠŞ", "tťŧţ", "TŤŦŢ", "uúùûüŭůűũųū", "UÚÙÛÜŬŮŰŨŲŪ", "wŵ", "WŴ", "yýÿŷ", "YÝŶŸ", "zźžż", "ZŹŽŻ" };
            string[] tr2 = new string[8] { "aeæ", "AEÆ", "oeœ", "OEŒ", "ssß", "ijij", "ngŋ", "NGŊ" };
 
            foreach (string t in tr1)
            {
                key = Regex.Replace(key, @"[" + t.Substring(1) + @"]", t.Substring(0, 1));
            }
            foreach (string t in tr2)
            {
                key = Regex.Replace(key, @"[" + t.Substring(2) + @"]", t.Substring(0, 2));
            }
 
            return key;
        }
 
        private string Key(Match m)
        {
            return "DEFAULTSORT:" + CleanKey(m.Groups[1].Value);
        }



Articles non modifiés :