/// <summary> /// List of all the property /// </summary> /// <param name="lang">language to use</param> private void PropertyTable(string lang) { WikimediaAPI WD = new WikimediaAPI("https://www.wikidata.org", User, Password); int From = 1; int To = 2000; int cont = 0; int cont1 = 0; string result = "{| class=\"wikitable sortable\"" + Environment.NewLine; result += "! Property !! type !! label !! description" + Environment.NewLine; string list = ""; for (cont = From; cont <= To; cont += 1) { list = ""; for (cont1 = cont; cont1 <= cont + 500 - 1; cont1 += 1) //era 200 { list += "P" + cont1 + "|"; } cont = cont1 - 1; list = list.Remove(list.LastIndexOf("|")); string strJson = WD.LoadWD(list, WikimediaAPI.LoadTypeWD.All); Entities itemList = new Entities(); itemList = JsonConvert.DeserializeObject <Entities>(strJson, new DatavalueConverter()); foreach (KeyValuePair <string, Entity> entity in itemList.entities) { Entity ent = entity.Value; if (ent.datatype != null) { string lab = ""; if (ent.labels.ContainsKey(lang) && ent.labels != null) { lab = ent.labels[lang].value; } string desc = ""; if (ent.descriptions != null && ent.descriptions.ContainsKey("it")) { desc = ent.descriptions[lang].value; } result += "|-" + Environment.NewLine; result += "| " + "[[Property:" + ent.id + "|" + ent.id + "]]" + " || " + ent.datatype + " ||" + lab + " || " + desc + Environment.NewLine; } } } result += "|}"; string res = WD.SavePage("User:ValterVBot/Labels and descriptions/it/Property", result, "Upd"); }
private void LabelDescription() { WikimediaAPI WD = new WikimediaAPI("https://www.wikidata.org", User, Password); txtPageList.AppendText(DateTime.Now.ToLongTimeString() + Environment.NewLine); int From = 1; int To = 111500; int cont = 0; int cont1 = 0; string list = ""; int daScrivere = 5000; List <string> LingueList = new List <string> { "de", "en", "es", "fr", "it", "hu", "ru", }; //Add language here int Lingue = LingueList.Count(); Dictionary <string, List <LabDesc> > elenco = new Dictionary <string, List <LabDesc> >(); foreach (string lang in LingueList) { elenco.Add(lang, new List <LabDesc>()); } for (cont = From; cont <= To; cont += 1) { list = ""; for (cont1 = cont; cont1 <= cont + 500 - 1; cont1 += 1) //era 200 { list += "Q" + cont1 + "|"; } cont = cont1 - 1; list = list.Remove(list.LastIndexOf("|")); string strJson = WD.LoadWD(list, WikimediaAPI.LoadTypeWD.LabelDescriptionSitelink); Entities itemList = new Entities(); itemList = JsonConvert.DeserializeObject <Entities>(strJson, new DatavalueConverter()); Lingue = LingueList.Count(); foreach (KeyValuePair <string, Entity> entity in itemList.entities) { Entity ent = entity.Value; Lingue = LingueList.Count(); if (ent.type != null && !ent.IsRedirect) { foreach (string lang in LingueList) { if (elenco[lang].Count == daScrivere) { Lingue -= 1; } else { List <LabDesc> list2 = elenco[lang]; LabDesc labdesc = new LabDesc(ent, lang); if (labdesc.item != null) { list2.Add(labdesc); } } } } if (Lingue == 0) { break; } } if (Lingue == 0) { break; } } string Tab = ""; foreach (string lang in LingueList) { string header = ""; switch (lang) { case "de": header = "== Liste der Objekte ohne deutsche Bezeichnung und/oder Beschreibung ==" + Environment.NewLine; header += "Die ersten 5000 Objekte mit Interwikilinks. Aggiornato al : " + DateTime.Now + Environment.NewLine; break; case "en": header = "== List of item without English labels and/or descriptions ==" + Environment.NewLine; header += "First 5000 items with wiki sitelink. Update : " + DateTime.Now + Environment.NewLine; break; case "es": header = "== List of item without Spanish labels and/or descriptions ==" + Environment.NewLine; header += "First 5000 items with wiki sitelink. Update : " + DateTime.Now + Environment.NewLine; break; case "it": header = "== Lista di elementi senza etichetta e/o descrizione in italiano ==" + Environment.NewLine; header += "Primi 5000 elementi con wiki sitelink. Aggiornato al : " + DateTime.Now + Environment.NewLine; break; default: header = "== List of item without " + lang + " labels and/or descriptions ==" + Environment.NewLine; header += "First 5000 items with wiki sitelink. Update : " + DateTime.Now + Environment.NewLine; break; } Tab = header + Environment.NewLine; Tab += "{| class=\"wikitable sortable\"" + Environment.NewLine; Tab += "! Item !! label !! description !! sitelink" + Environment.NewLine; foreach (LabDesc ld in elenco[lang]) { Tab += "|-" + Environment.NewLine; Tab += "| [[" + ld.item + "]] || " + ld.label + " || " + ld.description + " || " + ld.sitelink + Environment.NewLine; } Tab += "|}"; string res = WD.SavePage("User:ValterVBot/Labels and descriptions/" + lang, Tab, "Update"); Console.Write(""); } txtPageList.AppendText(DateTime.Now.ToLongTimeString() + Environment.NewLine); }