Difference between revisions of "SimpleGraph-MediaWiki"
Jump to navigation
Jump to search
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | =SimpleGraphModule= | ||
+ | |||
{{SimpleGraphModule | {{SimpleGraphModule | ||
|name=MediaWiki | |name=MediaWiki | ||
+ | |logo=File:Mediawiki logo reworked.svg | ||
+ | |modulename=mediawiki | ||
+ | |systemname=MediaWikiSystem | ||
+ | |url=https://www.mediawiki.org/wiki/API:Main_page MediaWiki | ||
+ | |apiname=MediaWiki API | ||
+ | |apiurl=https://www.mediawiki.org/wiki/API:Main_page | ||
+ | |issue=3 | ||
|documentation=makes MediaWiki site content accessible to Graph processing. | |documentation=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. | 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. | ||
− | |||
− | |||
|storemode=property | |storemode=property | ||
|viewmode=hidden | |viewmode=hidden |
Latest revision as of 08:49, 13 December 2018
SimpleGraphModule
SimpleGraph MediaWiki module
The SimpleGraph MediaWiki MediaWiki module makes MediaWiki site content accessible to Graph processing. It exposes the MediaWiki API using the mediawiki-japi Library by BITPlan. see MediaWiki API. The initial issue is 3
Sources
- System: MediaWikiSystem.java
- JUnit-Test: TestMediaWikiSystem.java
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
The following JUnit test case gets a single page as a node. The properties "pageTitle" and "pageContent" are set for each node.
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]]"));
}