From BITPlan Wiki
Jump to: navigation, search


SemanticMediaWiki Logo.png

SimpleGraph SMW module

The SimpleGraph SMW module makes SemanticMediaWiki accessible via the SMW API see SemanticMedia Wiki API.



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:

SimpleGraph-ExcelExcelexcelExcelSystem ExcelApache POI XSSF/HSSF Microsoft Excel workbooks accessible via the Apache POI API
SimpleGraph-FileSystemFileSystemfilesystemFileSystem your FileSystem accessible via the Java FileSystem API
SimpleGraph-HTMLHTMLhtmlHtmlSystem Cleaner HTML files accessible via HTML Cleaner parser
SimpleGraph-JSONJSONjsonJsonSystem Object NotationJSON JSON parse results accessible to Graph processing.
SimpleGraph-JavaJavajavaJavaSystem (programming language)javaparser Java code parse results accessible to Graph processing.
SimpleGraph-MapSystemMapSystemmapMapSystem tablejava.api.Map a simple wrapper for a graph with nodes that have key/value pairs in form of HashMaps. We would not really need this since Apache Tinkerpop/Gremlin already supplies us with properties per node/vertex. Still this system is useful as a helper system and to illustrate the wrapping concepts and possibilities of SimpleGraph
SimpleGraph-MediaWikiMediaWikimediawikiMediaWikiSystem page MediaWikiMediaWiki API pagemakes MediaWiki site content accessible to Graph processing. It exposes the MediaWiki API using the mediawiki-japi Library by BITPlan.
SimpleGraph-PDFPDFpdfPdfSystem Document FormatApache PDFBox Portable Document Format (PDF) files accessible via the Apache PDFBox® API
SimpleGraph-PowerPointPowerPointpowerpointPowerPointSystem PowerPointApache POI XSLF/HSLF Microsoft PowerPoint presentations accessible via the Apache POI API
SimpleGraph-SMWSMWsmwSmwSystem Wiki API SemanticMediaWiki accessible via the SMW API
SimpleGraph-SNMPSNMPsnmpSNMPSystem Network Management ProtocolSNMP4J Simple Network Monitoring Protocol SNMP Java API Simple Network Monitoring Protocol accessible via SNMP4J
SimpleGraph-SQLSQLsqlSQLSystem Database Connectivity (JDBC) API relational SQL databases accessible via the Java JDBC API.
SimpleGraph-TripleStoreTripleStoretriplestoreTripleStoreSystem BITPlan's SiDIF educational TripleStore accessible
SimpleGraph-WikiDataWikiDatawikidataWikiDataSystem Toolkit WikiData data available via the Wikidata-Toolki API
SimpleGraph-WordWordwordWordSystem POI XWPF/HWPF Microsoft Word Documents accessible via the Apache POI API
SimpleGraph-XMLXMLxmlXmlSystem XML dom parse results accessible to Graph processing.
SimpleGraph-githubGitHubgithubGitHubSystemhttps://github.comGitHub GraphQL Api v4 GitHub content accessible to Graph processing.

The corresonding SMW ask query is

{{#ask: [[Concept: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
|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.connect("", "/");
    smw.moveTo("ask=" + askQuery);
    if (debug)
    List<Vertex> moduleVs = smw.getStartNode().g().V()