Created
May 4, 2013 00:29
-
-
Save ansell/5515394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog-admin db create -n testRulesDB ~/Downloads/rules.ttl | |
Bulk loading data to new database. | |
Loading data completed...Loaded 42 triples in 00:00:00 @ 0.3K triples/sec. | |
Successfully created database 'testRulesDB'. | |
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog query "testRulesDB;reasoning=QL" "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
> PREFIX owl: <http://www.w3.org/2002/07/owl#> | |
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
> PREFIX :<http://www.semanticweb.org/ontologies/2013/3/untitled-ontology-104#> | |
> SELECT ?x ?z | |
> WHERE { ?x :f2 ?z }" | |
+-------------------------+--------------------------------------------------+ | |
| x | z | | |
+-------------------------+--------------------------------------------------+ | |
| untitled-ontology-104:a | "11.0"^^<http://www.w3.org/2001/XMLSchema#float> | | |
+-------------------------+--------------------------------------------------+ | |
Query returned 1 results in 00:00:00.128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog-admin db drop -n testRulesDB | |
Successfully deleted database 'testRulesDB'. | |
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog-admin db create -n testRulesDB | |
Successfully created database 'testRulesDB'. | |
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog data add -u admin -p admin testRulesDB ~/Downloads/rules.ttl | |
Adding data from file: /Users/mhgrove/Downloads/rules.ttl | |
Added 42 RDF triples. | |
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog query "testRulesDB;reasoning=QL" "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX owl: <http://www.w3.org/2002/07/owl#> | |
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX :<http://www.semanticweb.org/ontologies/2013/3/untitled-ontology-104#> | |
SELECT ?x ?z | |
WHERE { ?x :f2 ?z }" | |
+----------------------------------------------------------------------+--------------------------------------------------+ | |
| x | z | | |
+----------------------------------------------------------------------+--------------------------------------------------+ | |
| http://www.semanticweb.org/ontologies/2013/3/untitled-ontology-104#a | "11.0"^^<http://www.w3.org/2001/XMLSchema#float> | | |
+----------------------------------------------------------------------+--------------------------------------------------+ | |
Query returned 1 results in 00:00:00.041 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2010 - 2013, Clark & Parsia, LLC. <http://www.clarkparsia.com> | |
// For more information about licensing and copyright of this software, please contact | |
// [email protected] or visit http://stardog.com | |
package com.clarkparsia.stardog; | |
import java.io.File; | |
import com.clarkparsia.stardog.api.Connection; | |
import com.clarkparsia.stardog.reasoning.ReasoningType; | |
import org.openrdf.query.TupleQueryResult; | |
import org.openrdf.rio.RDFFormat; | |
/** | |
* <p></p> | |
* | |
* @author Michael Grove | |
* @since 0 | |
* @version 0 | |
*/ | |
public class TestSWRL { | |
public static void main(String[] args) throws Exception { | |
StardogDBMS.startEmbeddedServer(); | |
StardogDBMS dbms = StardogDBMS.toEmbeddedServer() | |
.credentials("admin", "admin".toCharArray()) | |
.login(); | |
try { | |
Connection aConn = dbms.createMemory("temp") | |
.reasoning(ReasoningType.QL) | |
.credentials("admin", "admin") | |
.connect(); | |
aConn.begin(); | |
aConn.add() | |
.io() | |
.format(RDFFormat.TURTLE) | |
.file(new File("/Users/mhgrove/Downloads/rules.ttl")); | |
aConn.commit(); | |
String aQuery = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + | |
"PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + | |
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" + | |
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + | |
"PREFIX :<http://www.semanticweb.org/ontologies/2013/3/untitled-ontology-104#>\n" + | |
"SELECT ?x ?z\n" + | |
"WHERE { ?x :f2 ?z }"; | |
TupleQueryResult aResults = aConn.query(aQuery).executeSelect(); | |
while (aResults.hasNext()) { | |
System.out.println(aResults.next()); | |
} | |
aResults.close(); | |
} | |
finally { | |
dbms.logout(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment