My favorites | Sign in
Project Logo
                
Changes to /trunk/src/example/java/example/thing/SiocWriteExample.java
r737 vs. r739   Edit
  Compare: vs.   Format:
Revision r739
Go to: 
Project members, sign in to write a code review
/trunk/src/example/java/example/thing/SiocWriteExample.java   r737 /trunk/src/example/java/example/thing/SiocWriteExample.java   r739
1 package example.thing; 1 package example.thing;
2 2
3 import thewebsemantic.Thing; 3 import thewebsemantic.Thing;
4 import thewebsemantic.vocabulary.Rdfs; 4 import thewebsemantic.vocabulary.Rdfs;
5 import thewebsemantic.vocabulary.Sioc; 5 import thewebsemantic.vocabulary.Sioc;
6 6
7 import com.hp.hpl.jena.ontology.OntModel; 7 import com.hp.hpl.jena.rdf.model.Model;
8 import com.hp.hpl.jena.ontology.OntModelSpec;
9 import com.hp.hpl.jena.rdf.model.ModelFactory; 8 import com.hp.hpl.jena.rdf.model.ModelFactory;
10 import com.hp.hpl.jena.rdf.model.RDFWriter; 9 import com.hp.hpl.jena.rdf.model.RDFWriter;
11 10
12 public class SiocWriteExample { 11 public class SiocWriteExample {
13 private static final String uri9 = "http://johnbreslin.com/blog/category/semantic-web/"; 12 private static final String uri9 = "http://johnbreslin.com/blog/category/semantic-web/";
14 private static final String literal1 = "SIOC provides a unified vocabulary for content and interaction description: a semantic layer that can co-exist with existing discussion platforms."; 13 private static final String literal1 = "SIOC provides a unified vocabulary for content and interaction description: a semantic layer that can co-exist with existing discussion platforms.";
15 private static final String uri8 = "http://johnbreslin.com/blog/index.php?sioc_type=comment&sioc_id=123928"; 14 private static final String uri8 = "http://johnbreslin.com/blog/index.php?sioc_type=comment&sioc_id=123928";
16 private static final String uri7 = "http://johnbreslin.com/blog/2006/09/07/creating-connections-between-discussion-clouds-with-sioc/#comment-123928"; 15 private static final String uri7 = "http://johnbreslin.com/blog/2006/09/07/creating-connections-between-discussion-clouds-with-sioc/#comment-123928";
17 private static final String uri6 = "http://johnbreslin.com/blog/category/blogs/"; 16 private static final String uri6 = "http://johnbreslin.com/blog/category/blogs/";
18 private static final String uri4 = "http://johnbreslin.com/blog/index.php?sioc_type=user&sioc_id=1"; 17 private static final String uri4 = "http://johnbreslin.com/blog/index.php?sioc_type=user&sioc_id=1";
19 private static final String uri3 = "http://johnbreslin.com/blog/author/cloud/"; 18 private static final String uri3 = "http://johnbreslin.com/blog/author/cloud/";
20 private static final String uri2 = "http://johnbreslin.com/blog/index.php?sioc_type=site#weblog"; 19 private static final String uri2 = "http://johnbreslin.com/blog/index.php?sioc_type=site#weblog";
21 private static final String uri1 = "http://johnbreslin.com/blog/2006/09/07/creating-connections-between-discussion-clouds-with-sioc/"; 20 private static final String uri1 = "http://johnbreslin.com/blog/2006/09/07/creating-connections-between-discussion-clouds-with-sioc/";
22 21
23 public static void main(String[] args) { 22 public static void main(String[] args) {
24 OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF); 23 Model m = ModelFactory.createDefaultModel();
25 m.setNsPrefix("sioc", "http://rdfs.org/sioc/ns#"); 24 m.setNsPrefix("sioc", Sioc.NS);
26
27 Thing thing = new Thing(m); 25 Thing thing = new Thing(m);
28 thing.at(uri1). 26 thing.at(uri1).
29 isa(Sioc.Post.class). 27 isa(Sioc.Post.class).
30 has_container(thing.at(uri2)). 28 has_container(thing.at(uri2)).
31 has_creator( 29 has_creator(
32 thing.at(uri3).isa(Sioc.User.class). 30 thing.at(uri3).isa(Sioc.User.class).
33 seeAlso( thing.at(uri4))). 31 seeAlso( thing.at(uri4))).
34 content(literal1). 32 content(literal1).
35 topic(thing.at(uri6).as(Rdfs.class).label("blogs")). 33 topic(thing.at(uri6).as(Rdfs.class).label("blogs")).
36 topic(thing.at(uri9).as(Rdfs.class).label("SemanticWeb")). 34 topic(thing.at(uri9).as(Rdfs.class).label("SemanticWeb")).
37 has_reply( 35 has_reply(
38 thing.at(uri7). 36 thing.at(uri7).
39 isa(Sioc.Post.class). 37 isa(Sioc.Post.class).
40 seeAlso(thing.at(uri8))); 38 seeAlso(thing.at(uri8)));
41 39
42 // this intends to format the rdf as closely as possible 40 // this intends to format the rdf as closely as possible
43 // with the example being duplicated. 41 // with the example being duplicated.
44 RDFWriter w = m.getWriter("RDF/XML-ABBREV"); 42 RDFWriter w = m.getWriter("RDF/XML-ABBREV");
45 w.setProperty( "blockRules" , "" ); 43 w.setProperty( "blockRules" , "" );
46 w.write(m.getBaseModel(), System.out, null); 44 w.write(m, System.out, null);
47 45
48 } 46 }
49 } 47 }
Hosted by Google Code