SimpleGraph-SMW: Difference between revisions
No edit summary |
|||
| Line 9: | Line 9: | ||
|apiname=SemanticMedia Wiki API | |apiname=SemanticMedia Wiki API | ||
|apiurl=https://www.semantic-mediawiki.org/wiki/Help:API | |apiurl=https://www.semantic-mediawiki.org/wiki/Help:API | ||
|documentation=makes | |documentation=makes {{Link|target=Semantic MediaWiki}} accessible via the SMW API | ||
|storemode=property | |storemode=property | ||
|viewmode=hidden | |viewmode=hidden | ||
}} | }} | ||
= Example = | = Example = | ||
With the SimpleGraph SMW module you can access Semantic MediaWiki query results and process them with Gremlin. | With the SimpleGraph SMW module you can access Semantic MediaWiki query results and process them with Gremlin. | ||
Latest revision as of 06:56, 18 February 2019
SimpleGraphModule
SimpleGraph SMW module
The SimpleGraph SMW module makes Semantic MediaWiki accessible via the SMW API see SemanticMedia Wiki API.
Sources
- System: SmwSystem.java
- JUnit-Test: TestSmwSystem.java
Example
With the SimpleGraph SMW module you can access Semantic MediaWiki query results and process them with Gremlin. Since this Webpage is based on SemanticMediaWiki we can use content from this wiki to explain the concepts. Let's eq.g. query the available SimpleGraph modules:
The corresonding SMW ask query is
{{#ask: [[Concept:SimpleGraphModule]]
|mainlabel=SimpleGraphModule
|?SimpleGraphModule name = name
|?SimpleGraphModule logo = logo
|?SimpleGraphModule modulename = modulename
|?SimpleGraphModule systemname = systemname
|?SimpleGraphModule url = url
|?SimpleGraphModule apiname = apiname
|?SimpleGraphModule apiurl = apiurl
|?SimpleGraphModule documentation = documentation
|format=table
|order=?SimpleGraphModule name
}}
JUnit Test
The following Unit Test now shows how you can convert such an Ask Query to a graph structure. Each result row will be converted to a Vertex in the graph. The name of the Vertex is derived from the Concept-Name you queried automatically (if there is a Concept condition in the query). You can also give the name of the vertex labels as parameter.
public void testSimpleGraphModules() throws Exception {
String askQuery = "{{#ask: [[Concept:SimpleGraphModule]]\n"
+ "|mainlabel=SimpleGraphModule\n"
+ "| ?SimpleGraphModule name = name\n"
+ "| ?SimpleGraphModule logo = logo\n"
+ "| ?SimpleGraphModule modulename = modulename\n"
+ "| ?SimpleGraphModule systemname = systemname\n"
+ "| ?SimpleGraphModule url = url\n"
+ "| ?SimpleGraphModule apiname = apiname\n"
+ "| ?SimpleGraphModule apiurl = apiurl\n"
+ "| ?SimpleGraphModule documentation = documentation\n" + "}}";
SmwSystem smw = new SmwSystem();
// debug = true;
smw.setDebug(debug);
smw.connect("http://wiki.bitplan.com", "/");
smw.moveTo("ask=" + askQuery);
if (debug)
smw.forAll(SimpleNode.printDebug);
List<Vertex> moduleVs = smw.getStartNode().g().V()
.hasLabel("SimpleGraphModule").toList();
}
Module for SE: true

