SimpleGraph-SMW

From BITPlan Wiki
Jump to: navigation, search

SimpleGraphModule

SemanticMediaWiki Logo.png

SimpleGraph SMW module

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

Sources

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:

SimpleGraphModulenamemodulenamesystemnameurlapinameapiurldocumentation
SimpleGraph-CalDAVCalDAVcaldavCaldavSystemhttps://en.wikipedia.org/wiki/CalDAVical4j library for parsing and building iCalendar data modelshttps://github.com/ical4j/ical4jmakes Calendar data available via ical4j
SimpleGraph-CardDAVCardDAVcarddavCarddavSystemhttps://en.wikipedia.org/wiki/CardDAVmakes VCard data available
SimpleGraph-ExcelExcelexcelExcelSystemhttps://en.wikipedia.org/wiki/Microsoft ExcelApache POI XSSF/HSSFhttps://poi.apache.org/components/spreadsheet/quick-guide.htmlmakes Microsoft Excel workbooks accessible via the Apache POI API
SimpleGraph-FileSystemFileSystemfilesystemFileSystemhttps://en.wikipedia.org/wiki/File systemjava.io.Filehttps://docs.oracle.com/javase/8/docs/api/java/io/File.htmlmakes your FileSystem accessible via the Java FileSystem API
SimpleGraph-GeoJSONGeoJSONgeojsonGeoJsonSystemhttps://en.wikipedia.org/wiki/GeoJSONGeoJSON support for Google gson libraryhttps://github.com/filosganga/geogsonmakes GeoJSON data available
SimpleGraph-HTMLHTMLhtmlHtmlSystemhttps://en.wikipedia.org/wiki/HTMLHTML Cleanerhttp://htmlcleaner.sourceforge.net/makes HTML files accessible via HTML Cleaner parser
SimpleGraph-JSONJSONjsonJsonSystemhttps://en.wikipedia.org/wiki/JavaScript Object NotationJSONhttps://www.json.org/makes JSON parse results accessible to Graph processing.
SimpleGraph-JavaJavajavaJavaSystemhttps://en.wikipedia.org/wiki/Java (programming language)javaparserhttps://github.com/javaparser/javaparsermakes Java code parse results accessible to Graph processing.
SimpleGraph-MailMailmailMailSystemhttps://en.wikipedia.org/wiki/MIMEE-Mail access for rfc822 and MIME formatted Mailbox files (e.g. Thunderbird)https://james.apache.org/mime4j/makes Mail data available via Apache Mime4J
SimpleGraph-MapSystemMapSystemmapMapSystemhttps://en.wikipedia.org/wiki/Hash tablejava.api.Maphttps://docs.oracle.com/javase/8/docs/api/java/util/Map.htmlsupplies 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-MediaWikiMediaWikimediawikiMediaWikiSystemhttps://www.mediawiki.org/wiki/API:Main page MediaWikiMediaWiki APIhttps://www.mediawiki.org/wiki/API:Main pagemakes MediaWiki site content accessible to Graph processing. It exposes the MediaWiki API using the mediawiki-japi Library by BITPlan.
SimpleGraph-PDFPDFpdfPdfSystemhttps://de.wikipedia.org/wiki/Portable Document FormatApache PDFBoxhttps://pdfbox.apache.org/makes Portable Document Format (PDF) files accessible via the Apache PDFBox® API
SimpleGraph-PowerPointPowerPointpowerpointPowerPointSystemhttps://en.wikipedia.org/wiki/Microsoft PowerPointApache POI XSLF/HSLFhttps://poi.apache.org/slideshow/xslf-cookbook.htmlmakes Microsoft PowerPoint presentations accessible via the Apache POI API
SimpleGraph-SMWSMWsmwSmwSystemhttps://en.wikipedia.org/wiki/SMWSemanticMedia Wiki APIhttps://www.semantic-mediawiki.org/wiki/Help:APImakes SemanticMediaWiki accessible via the SMW API
SimpleGraph-SNMPSNMPsnmpSNMPSystemhttps://en.wikipedia.org/wiki/Simple Network Management ProtocolSNMP4J Simple Network Monitoring Protocol SNMP Java APIhttp://www.snmp4j.org/makes Simple Network Monitoring Protocol accessible via SNMP4J
SimpleGraph-SQLSQLsqlSQLSystemhttps://en.wikipedia.org/wiki/SQLJava Database Connectivity (JDBC) APIhttps://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.htmlmakes relational SQL databases accessible via the Java JDBC API.
SimpleGraph-TripleStoreTripleStoretriplestoreTripleStoreSystemhttps://en.wikipedia.org/wiki/TriplestoreSiDIF-TripleStorehttps://github.com/BITPlan/org.sidif.triplestoremakes BITPlan's SiDIF educational TripleStore accessible
SimpleGraph-WikiDataWikiDatawikidataWikiDataSystemhttps://en.wikipedia.org/wiki/WikidataWikiData Toolkithttps://github.com/Wikidata/Wikidata-Toolkitmakes WikiData data available via the Wikidata-Toolki API
SimpleGraph-WordWordwordWordSystemhttps://en.wikipedia.org/wiki/WordApache POI XWPF/HWPFhttps://poi.apache.org/document/quick-guide-xwpf.htmlmakes Microsoft Word Documents accessible via the Apache POI API
SimpleGraph-XMLXMLxmlXmlSystemhttps://en.wikipedia.org/wiki/XMLorg.w3c.domhttps://docs.oracle.com/javase/7/docs/api/org/w3c/dom/package-summary.htmlmakes XML dom parse results accessible to Graph processing.
SimpleGraph-githubGitHubgithubGitHubSystemhttps://github.comGitHub GraphQL Api v4https://developer.github.com/v4/makes GitHub content accessible to Graph processing.

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();
}