Főmenü megnyitása

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.

ModulokSzerkesztés

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;
}

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