Wikipédia:AutoWikiBrowser modulok

Az AutoWikiBrowser nem csak automatikus szövegcseréket képes elvégezni, hanem a tudását további modulokkal is bővíthetjük. Egyszerre csak egy modult használhatunk, melyet a .../moduls menüpontban kell elindítani.

Ha ki szeretnénk kapcsolni a modult, egyszerűen csak vegyük ki a pipát az Enabled szó előtti jelölőnégyzetből.

Szöveg beszúrása a szócikkek végére, a kategóriák eléSzerkesztés

Ez a modul csak egy egyszerű szöveget szúr be a szócikk végéhez, a kategóriák elé.

        public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "";

            Match m = Regex.Match(ArticleText, @"\[\[[Kk]ategória:");

            if (m.Success) ArticleText = ArticleText.Insert(m.Index, "foo\r\n");
            else ArticleText += "\r\nfoo";

            return ArticleText;
        }

Infoboxok tartalmának fájlba írásaSzerkesztés

Ez a modul a megadott feltételeknek megfelelő cikkek infoboxából olvassa ki az adatokat, majd menti el egy txt fájlba.

private static readonly Regex InfoboxUKplace = Tools.NestedTemplateRegex(new List<string>("infobox UK place".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string country="", static_image="", static_image_caption="";
          string latitude="", longitude="", official_name="";
          string population="", population_ref="", civil_parish="";
          string unitary_england="", lieutenancy_england="", region="";
          string constituency_westminster="", post_town="", postcode_district="";
          string dial_code="", os_grid_reference="";

          Skip = true;
          Summary = "";

          foreach(Match m in InfoboxUKplace.Matches(ArticleText))
          {
                string InfoboxUKplaceCall = m.Value;
                country = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"country");
                static_image = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"static_image");
                static_image_caption = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"static_image_caption");
                latitude = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"latitude");
                longitude = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"longitude");
                official_name = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"official_name");
                population = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"population");
                population_ref = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"population_ref");
                civil_parish = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"civil_parish");
                unitary_england = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"unitary_england");
                lieutenancy_england = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"lieutenancy_england");
                region = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"region");
                constituency_westminster = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"constituency_westminster");
                post_town = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"post_town");
                postcode_district = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"postcode_district");
                dial_code = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"dial_code");
                os_grid_reference = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"os_grid_reference");
          }

          System.IO.StreamWriter sw = System.IO.File.AppendText("C:/Projects/Infodata.txt");
          sw.WriteLine(ArticleTitle + "~" + country + "~" + static_image + "~" + static_image_caption + "~" + latitude + "~" + longitude + "~" + official_name 
          + "~" + population + "~" + population_ref + "~" + civil_parish + "~" + unitary_england + "~" + lieutenancy_england + "~" + region + "~" + constituency_westminster
          + "~" + post_town + "~" + postcode_district + "~" + dial_code + "~" + os_grid_reference);
          sw.Close();
          return ArticleText;
}

Modul olasz vasútállomásokhozSzerkesztés

private static readonly Regex InfoboxGare = Tools.NestedTemplateRegex(new List<string>("Infobox stazione ferroviaria".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string immagine="", localizzazione="", linea="";
          string apertura="", binari="";
 
          Skip = true;
          Summary = "";
 
          foreach(Match m in InfoboxGare.Matches(ArticleText))
          {
                string InfoboxGareCall = m.Value;
                immagine = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxGareCall,"immagine");
                localizzazione = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxGareCall,"localizzazione");
                linea = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxGareCall,"linea");
                apertura = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxGareCall,"apertura");
                binari = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxGareCall,"binari");

          }
 
          System.IO.StreamWriter sw = System.IO.File.AppendText("C:/mentés/Infodata.txt");
          sw.WriteLine(ArticleTitle + "~" + immagine + "~" + localizzazione + "~" + linea + "~" + apertura + "~" + binari);
          sw.Close();
          return ArticleText;
}

Modul magyar infoboxból csak képek kinyeréséhezSzerkesztés

private static readonly Regex Infobox = new Regex(Tools.NestedTemplateRegex("foo").ToString().Replace(@"[Ff]oo", @"\w[\w -]*? infobox"));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string img="";
 
          Skip = true;
          Summary = "";
 
          foreach(Match m in Infobox.Matches(ArticleText))
          {
                string InfoboxCall = m.Value;
                img = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxCall, "kép");
          }

          if(img != null && img != "")
          {
                img = img.Replace("_", " ");

                System.IO.StreamWriter sw = System.IO.File.AppendText("C:/az/eleresi/ut/fajlnev.txt");
                sw.WriteLine(ArticleTitle + "\tP18\t\"" + img + "\"\tS143\tQ53464");
                sw.Close();
          }
          return ArticleText;
}

Modul holland infoboxból csak képek kinyeréséhezSzerkesztés

private static readonly Regex Infobox = new Regex(Tools.NestedTemplateRegex("foo").ToString().Replace(@"infobox [Ff]oo", @"\w[\w -]*?"));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string afbeelding="";
 
          Skip = true;
          Summary = "";
 
          foreach(Match m in Infobox.Matches(ArticleText))
          {
                string InfoboxCall = m.Value;
                afbeelding = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxCall, "kép");
          }

          if(img != null && img != "")
          {
                afbeelding = afbeelding.Replace("_", " ");

                System.IO.StreamWriter sw = System.IO.File.AppendText("C:/az/eleresi/ut/fajlnev.txt");
                sw.WriteLine(ArticleTitle + "\tP18\t\"" + afbeelding + "\"\tS143\tQ53464");
                sw.Close();
          }
          return ArticleText;
}

Modul amerikai megyékhez a határos települések sablonhozSzerkesztés

private static readonly Regex InfoboxUKplace = Tools.NestedTemplateRegex(new List<string>("Geographic location".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string North="", Northeast="", East="";
          string Southeast="", South="", Southwest="";
          string West="", Northwest="";
          Skip = true;
          Summary = "";
          foreach(Match m in InfoboxUKplace.Matches(ArticleText))
          {
                string InfoboxUKplaceCall = m.Value;
                North = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"North");
                Northeast = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"Northeast");
                East = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"East");
                Southeast = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"Southeast");
                South = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"South");
                Southwest = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"Southwest");
                West = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"West");
                Northwest = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"Northwest");
          }
          System.IO.StreamWriter sw = System.IO.File.AppendText("e:/Infodata.txt");
          sw.WriteLine(ArticleTitle + ";" + North);
          sw.WriteLine(ArticleTitle + ";" + Northeast) ;
          sw.WriteLine(ArticleTitle + ";" + East );
          sw.WriteLine(ArticleTitle + ";" + Southeast) ;
          sw.WriteLine(ArticleTitle + ";" + South );
          sw.WriteLine(ArticleTitle + ";" + Northwest);
          sw.WriteLine(ArticleTitle + ";" + Southwest) ;
          sw.WriteLine(ArticleTitle + ";" + West);
          sw.Close();
          return ArticleText;
}

Modul fővárosok kinyeréséhez amerikai megyékbőlSzerkesztés

private static readonly Regex InfoboxUKplace = Tools.NestedTemplateRegex(new List<string>("Infobox U.S. County".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
          string seatwl="";
          Skip = true;
          Summary = "";
          foreach(Match m in InfoboxUKplace.Matches(ArticleText))
          {

                string InfoboxUKplaceCall = m.Value;
                seatwl = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"seat wl");

          }
          System.IO.StreamWriter sw = System.IO.File.AppendText("e:/Infodata.txt");
          sw.WriteLine(ArticleTitle + ";" + seatwl);

          sw.Close();
          return ArticleText;
}

Modul repülőterekhez kifutópálya adatok kinyeréséhezSzerkesztés

private static readonly Regex InfoboxUKplace = Tools.NestedTemplateRegex(new List<string>("infobox airport".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{

string r1_number ="";
string r1_length_m = "";
string r1_surface = "";
string r2_number = "";
string r2_length_m = "";
string r2_surface = "";
string r3_number ="";
string r3_length_m = "";
string r3_surface = "";
string r4_number = "";
string r4_length_m = "";
string r4_surface ="";
string r5_number ="";
string r5_length_m = "";
string r5_surface = "";
string r6_number = "";
string r6_length_m = "";
string r6_surface ="";
          
Skip = true;
Summary = "";

          foreach(Match m in InfoboxUKplace.Matches(ArticleText))
          {
                string InfoboxUKplaceCall = m.Value;

                r1_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r1-number");
                r1_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r1-length-m");
                r1_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r1-surface");

                r2_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r2-number");
                r2_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r2-length-m");
                r2_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r2-surface");

                r3_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r3-number");
                r3_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r3-length-m");
                r3_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r3-surface");

                r4_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r4-number");
                r4_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r4-length-m");
                r4_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r4-surface");

                r5_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r5-number");
                r5_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r5-length-m");
                r5_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r5-surface");

                r6_number = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r6-number");
                r6_length_m = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r6-length-m");
                r6_surface = WikiFunctions.Tools.GetTemplateParameterValue(InfoboxUKplaceCall,"r6-surface");
          }

                    System.IO.StreamWriter sw = System.IO.File.AppendText("d:/Infodata.txt");
          sw.WriteLine("[[:en:"+ArticleTitle+"]]");
          sw.WriteLine("| kifutó szög 1         = " + r1_number);
          sw.WriteLine("| kifutó hossz 1        = " + r1_length_m);
          sw.WriteLine("| kifutó burkolat 1     = " + r1_surface);
          sw.WriteLine("| kifutó szög 2         = " + r2_number);
          sw.WriteLine("| kifutó hossz 2        = " + r2_length_m);
          sw.WriteLine("| kifutó burkolat 2     = " + r2_surface);
          sw.WriteLine("| kifutó szög 3         = " + r3_number);
          sw.WriteLine("| kifutó hossz 3        = " + r3_length_m);
          sw.WriteLine("| kifutó burkolat 3     = " + r3_surface);
          sw.WriteLine("| kifutó szög 4         = " + r4_number);
          sw.WriteLine("| kifutó hossz 4        = " + r4_length_m);
          sw.WriteLine("| kifutó burkolat 4     = " + r4_surface);
          sw.WriteLine("| kifutó szög 5         = " + r5_number);
          sw.WriteLine("| kifutó hossz 5        = " + r5_length_m);
          sw.WriteLine("| kifutó burkolat 5     = " + r5_surface);
          sw.WriteLine("| kifutó szög 6         = " + r6_number);
          sw.WriteLine("| kifutó hossz 6        = " + r6_length_m);
          sw.WriteLine("| kifutó burkolat 6     = " + r6_surface);
          sw.WriteLine();
          sw.Close();
          return ArticleText;
}

Lehetséges hibákSzerkesztés

  • Ne használj ékezetet, szóközt vagy kötőjelet tartalmazó változókat;
  • Ügyelj arra, hogy a Skip fülön a Doesn't exist legyen kipipálva;

Lásd mégSzerkesztés