Difference between revisions of "SimpleGraph-MediaWiki"
Jump to navigation
Jump to search
(Created page with "= SimpleGraph MediaWiki module = The {{Link|target=SimpleGraph}} MediaWiki module makes MediaWiki site content accessible to Graph processing. == Example == === Goal === === R...") |
|||
Line 1: | Line 1: | ||
= SimpleGraph MediaWiki module = | = SimpleGraph MediaWiki module = | ||
The {{Link|target=SimpleGraph}} MediaWiki module makes MediaWiki site content accessible to Graph processing. | The {{Link|target=SimpleGraph}} MediaWiki module makes MediaWiki site content accessible to Graph processing. | ||
+ | It exposes the [https://www.mediawiki.org/wiki/API:Main_page MediaWiki API] using the [http://mediawiki-japi.bitplan.com/index.php/Main_Page mediawiki-japi] Library by BITPlan. | ||
== Example == | == Example == | ||
=== Goal === | === Goal === | ||
+ | We'd like to get the pageContent of the MediaWiki article on [https://en.wikipedia.org/wiki/Cologne Cologne] | ||
=== Result === | === Result === | ||
+ | <pre> | ||
+ | ... | ||
+ | {{Infobox German location | ||
+ | |name = Cologne | ||
+ | |German_name = ''Köln'' | ||
+ | |type = City | ||
+ | |image_photo = Cologne montage.png | ||
+ | |imagesize = 270px | ||
+ | |image_caption = From top to bottom, left to right:<br /> | ||
+ | [[Hohenzollern Bridge]] by night, [[Great St. Martin Church]], [[Colonius]] TV-tower, [[Cologne Cathedral]], ''[[Kranhaus]]'' buildings in [[Rheinauhafen]], [[MediaPark]] | ||
+ | |image_coa =Großes Wappen von Köln.svg | ||
+ | |image_flag = Flagge Köln.svg | ||
+ | |image_plan = North rhine w K.svg | ||
+ | |plantext = Cologne within North Rhine-Westphalia | ||
+ | |coordinates = {{coord|50|56|11|N|6|57|10|E|format=dms|display=inline,title}} | ||
+ | |state = Nordrhein-Westfalen | ||
+ | |region = [[Cologne (region)|Cologne]] | ||
+ | |district = Urban districts of Germany | ||
+ | |elevation = 37 | ||
+ | |area = 405.15 | ||
+ | |population = 1057327 <!--Technical, do not add dots, references or other, the table is automatically updated--> | ||
+ | |pop_metro = 3573500 | ||
+ | |Stand = 2014/12/31 | ||
+ | |postal_code = 50441–51149 | ||
+ | |PLZ-alt = 5000 | ||
+ | |area_code = 0221, 02203 ([[Porz]]) | ||
+ | |licence = K | ||
+ | |Gemeindeschlüssel = 05 3 15 000 | ||
+ | |LOCODE = DE CGN | ||
+ | |mayor = [[Henriette Reker]] | ||
+ | |Bürgermeistertitel = [[Lord Mayor]] | ||
+ | |website = [http://www.stadt-koeln.de www.stadt-koeln.de] | ||
+ | |year = 38 BC | ||
+ | }} | ||
+ | ... | ||
+ | </pre> | ||
=== Explanation === | === Explanation === | ||
+ | ==== JUnit TestCase ==== | ||
+ | <source lang='java'> | ||
+ | @Test | ||
+ | public void testGetPage() throws Exception { | ||
+ | debug=true; | ||
+ | MediaWikiSystem mws = new MediaWikiSystem(); | ||
+ | MediaWikiPageNode pageNode = (MediaWikiPageNode) mws | ||
+ | .connect("https://en.wikipedia.org", "/w") | ||
+ | .moveTo("Cologne"); | ||
+ | if (debug) | ||
+ | pageNode.printNameValues(System.out); | ||
+ | String pageContent=pageNode.getProperty("pageContent").toString(); | ||
+ | assertTrue(pageContent.contains("[[Category:Cities in North Rhine-Westphalia]]")); | ||
+ | } | ||
+ | </source> | ||
[[Category:frontend]] | [[Category:frontend]] | ||
[[Category:SimpleGraph]] | [[Category:SimpleGraph]] |
Revision as of 09:14, 14 February 2018
SimpleGraph MediaWiki module
The SimpleGraph MediaWiki module makes MediaWiki site content accessible to Graph processing. It exposes the MediaWiki API using the mediawiki-japi Library by BITPlan.
Example
Goal
We'd like to get the pageContent of the MediaWiki article on Cologne
Result
... {{Infobox German location |name = Cologne |German_name = ''Köln'' |type = City |image_photo = Cologne montage.png |imagesize = 270px |image_caption = From top to bottom, left to right:<br /> [[Hohenzollern Bridge]] by night, [[Great St. Martin Church]], [[Colonius]] TV-tower, [[Cologne Cathedral]], ''[[Kranhaus]]'' buildings in [[Rheinauhafen]], [[MediaPark]] |image_coa =Großes Wappen von Köln.svg |image_flag = Flagge Köln.svg |image_plan = North rhine w K.svg |plantext = Cologne within North Rhine-Westphalia |coordinates = {{coord|50|56|11|N|6|57|10|E|format=dms|display=inline,title}} |state = Nordrhein-Westfalen |region = [[Cologne (region)|Cologne]] |district = Urban districts of Germany |elevation = 37 |area = 405.15 |population = 1057327 <!--Technical, do not add dots, references or other, the table is automatically updated--> |pop_metro = 3573500 |Stand = 2014/12/31 |postal_code = 50441–51149 |PLZ-alt = 5000 |area_code = 0221, 02203 ([[Porz]]) |licence = K |Gemeindeschlüssel = 05 3 15 000 |LOCODE = DE CGN |mayor = [[Henriette Reker]] |Bürgermeistertitel = [[Lord Mayor]] |website = [http://www.stadt-koeln.de www.stadt-koeln.de] |year = 38 BC }} ...
Explanation
JUnit TestCase
@Test
public void testGetPage() throws Exception {
debug=true;
MediaWikiSystem mws = new MediaWikiSystem();
MediaWikiPageNode pageNode = (MediaWikiPageNode) mws
.connect("https://en.wikipedia.org", "/w")
.moveTo("Cologne");
if (debug)
pageNode.printNameValues(System.out);
String pageContent=pageNode.getProperty("pageContent").toString();
assertTrue(pageContent.contains("[[Category:Cities in North Rhine-Westphalia]]"));
}