-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWikiBioSample.cs
More file actions
89 lines (80 loc) · 3.44 KB
/
WikiBioSample.cs
File metadata and controls
89 lines (80 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using WikiAccess;
namespace WikidataBioValidation
{
/// <summary>
/// Test and demo program that looks up a Wikidata item, finds the corresponding wikipedia article, finally comparing the two.
/// </summary>
class WikiBioSample
{
static void Main(string[] args)
{
int Qcode = 450675;
WikidataBiography WDperson = new WikidataBiography(Qcode);
List<ErrorLog> Errors = WDperson.GetErrors();
Console.WriteLine("----- Wikidata errors-----");
foreach (ErrorLog thisLog in Errors)
{
if (thisLog != null)
{
foreach (ErrorMessage Error in thisLog.Errors)
{
Console.WriteLine(Error.ToString());
}
}
}
Console.WriteLine("----- End of Wikidata errors-----");
if (WDperson.Found == true)
{
Console.WriteLine("----- Wikidata info-----");
Console.WriteLine(WDperson.Qcode);
Console.WriteLine(WDperson.Name);
Console.WriteLine(WDperson.Gender);
Console.WriteLine(WDperson.Description);
Console.WriteLine(WDperson.InstanceOf);
Console.WriteLine(WDperson.CitizenOf);
if (WDperson.DateOfBirth.Count > 0)
{
Console.WriteLine(WDperson.DateOfBirth[0].ToString());
}
if (WDperson.DateOfDeath.Count > 0)
{
Console.WriteLine(WDperson.DateOfDeath[0].ToString());
}
Console.WriteLine(WDperson.Wikilink);
Console.WriteLine("----- End of Wikidata info -----");
Console.WriteLine("--- Wikipedia article " + WDperson.Wikilink + " ---");
WikipediaBiography WPperson = new WikipediaBiography(WDperson.Wikilink);
Console.WriteLine(WPperson.Categories.Count.ToString() + " categories in article");
Console.WriteLine(WPperson.Templates.Count.ToString() + " templates in article");
Console.WriteLine("DEFAULTSORT " + WPperson.DefaultSort);
Console.WriteLine("DOB : " + WPperson.BirthDate.ToString());
Console.WriteLine("DOD : " + WPperson.DeathDate.ToString());
Console.WriteLine("--- End of Wikipedia article ---");
Console.WriteLine("----- Wikipedia errors-----");
foreach (ErrorLog thisLog in WPperson.GetErrors())
{
if (thisLog != null)
{
foreach (ErrorMessage Error in thisLog.Errors)
{
Console.WriteLine(Error.ToString());
}
}
}
Console.WriteLine("----- End of Wikipedia errors-----");
}
/*
WikiValidate Vperson = new WikiValidate(WDperson, WPperson);
if (Vperson.ErrorMessage != null)
{
foreach (string errormessage in WPperson.ErrorMessage)
{
Console.WriteLine(errormessage);
}
}
*/
}
}
}