Jena

9,108 views
9,027 views

Published on

Published in: Technology, Education
2 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total views
9,108
On SlideShare
0
From Embeds
0
Number of Embeds
1,270
Actions
Shares
0
Downloads
556
Comments
2
Likes
5
Embeds 0
No embeds

No notes for slide

Jena

  1. 1. Play with Jena Semantic Web Framework on Java Umi Laili Yuhana Master Candidate of Computer Science and Information Engineering National Taiwan University December 2007 http://yuhanaresearch.wordpress.com
  2. 2. Goal <ul><li>Provide material for beginner who want deal with JENA API </li></ul><ul><li>This work support lab material given in Advanced AI class on May 17, 2007 </li></ul><ul><li>Complete lab material can be found in Jena Lecture by C.F.Liao ( 廖峻鋒 ) on Advanced AI class on May 17,2007 in CSIE Department, National Taiwan University </li></ul>http://yuhanaresearch.wordpress.com
  3. 3. Outline <ul><li>RDF (Resource Description Framework) </li></ul><ul><li>JENA </li></ul><ul><li>Installing and Running Jena </li></ul>http://yuhanaresearch.wordpress.com
  4. 4. RDF http://yuhanaresearch.wordpress.com
  5. 5. RDF Example Example : CD list RDF Document for CD list http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  6. 6. RDF <ul><li>Stand for Resource Description Framework </li></ul><ul><li>W3C standard for describing resources on the web </li></ul><ul><li>Is designed to provide common way to describe information so it can be read and understood by computer application </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  7. 7. RDF <ul><li>RDF descriptions are not designed to be displayed on the web </li></ul><ul><li>Written in XML </li></ul><ul><li>Example : </li></ul><ul><ul><li>Describing properties for shopping items , such as price and availability </li></ul></ul><ul><ul><li>Describing information about web pages , such as content, author, created and modified date </li></ul></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  8. 8. RDF Model <ul><li>Model is a set of Statement </li></ul><ul><li>RDF statement : </li></ul><ul><ul><li>combination of a resource , a property , and a property value </li></ul></ul><ul><ul><li>Known as subject , predicate and object </li></ul></ul><ul><li>RDF use web identifier (URI) to identify resources </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  9. 9. RDF Statement and RDF Model <ul><li>Triple: T (subject, attribute, values) </li></ul><ul><li>Example : </li></ul><ul><ul><li>The artist of Empire Burlesque is Bob Dylan </li></ul></ul><ul><ul><li>The artist of http://www.recshop.fake/cd/ Empire Burlesque is Bob Dylan  (identify with resource/URI) </li></ul></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena Subject Object predicate
  10. 10. RDF Graph of Data Model Example http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  11. 11. RDF Element <ul><li>Root element </li></ul><ul><ul><li>defines the XML document to be an RDF document. </li></ul></ul><ul><ul><li>contains a reference to the RDF namespace </li></ul></ul><ul><li>Description element </li></ul><ul><ul><li>identifies a resource with the about attribute </li></ul></ul><ul><ul><li>contains elements that describe the resource </li></ul></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  12. 12. RDF Element (cont.) Root element Description Element http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  13. 13. RDF Element (cont.) Define XML document To be RDF Document RDF namespace About Attribut elements that describe the resource http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  14. 14. RDFS (RDF Schema) <ul><li>Extension of RDF </li></ul><ul><li>Describes resources with classes , properties , and values </li></ul><ul><li>P rovides the framework to describe application-specific classes and properties </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  15. 15. RDFS Example : the resource &quot;horse&quot; is a subclass of the class &quot;animal&quot; http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  16. 16. RDF OWL <ul><li>Stand for RDF Web Ontology Language </li></ul><ul><li>OWL : Language for processing Web Information </li></ul><ul><li>Build on top of RDF </li></ul><ul><li>stronger language with greater machine interpretability than RDF </li></ul><ul><li>Written in XML </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  17. 17. JENA Java API for semantic web applications http://yuhanaresearch.wordpress.com
  18. 18. Jena <ul><li>Java API for semantic web applications </li></ul><ul><li>Can be used to create and manipulate RDF graphs </li></ul><ul><li>Jena has : </li></ul><ul><ul><li>Resource interface  represent resources </li></ul></ul><ul><ul><li>Property interface  represent properties </li></ul></ul><ul><ul><li>Literal interface  represent literals </li></ul></ul><ul><ul><li>Model interface  represent graph </li></ul></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  19. 19. Example code to create graph with jena <ul><li>// some definitions </li></ul><ul><li>static String personURI = &quot;http://somewhere/JohnSmith&quot;; </li></ul><ul><li>static String fullName = &quot;John Smith&quot;; </li></ul><ul><li>// create an empty Model </li></ul><ul><li>Model model = ModelFactory.createDefaultModel(); </li></ul><ul><li>// create the resource </li></ul><ul><li>Resource johnSmith = model.createResource(personURI); </li></ul><ul><li>// add the property </li></ul><ul><li>johnSmith.addProperty(VCARD.FN, fullName); </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  20. 20. JENA RDF Package <ul><li>Key RDF package for the application developer is com.hp.jena.rdf.model </li></ul><ul><li>Package contain interfaces for representing: </li></ul><ul><ul><li>Models </li></ul></ul><ul><ul><li>Resources </li></ul></ul><ul><ul><li>Properties </li></ul></ul><ul><ul><li>Literals </li></ul></ul><ul><ul><li>Statements </li></ul></ul><ul><ul><li>All other key concept of RDF </li></ul></ul><ul><ul><li>ModelFactory for creating models </li></ul></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  21. 21. Installing and Running Jena http://yuhanaresearch.wordpress.com
  22. 22. Installing and Running Jena <ul><li>Download JDK 5 </li></ul><ul><li>Download and install Eclipse </li></ul><ul><li>Download Jena </li></ul><ul><li>Tuning your Eclipse </li></ul><ul><li>Create a java project </li></ul><ul><li>Append Jena libraries to your classpath </li></ul><ul><li>Use Jena API to create some RDFs </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  23. 23. Preparation the tools <ul><li>Download JDK 5 from http://java.sun.com/javase/downloads/index_jdk5.jsp </li></ul><ul><li>Download and Install Eclipse from http://www.eclipse.org/downloads/ </li></ul><ul><li>Download Jena from http://jena.sourceforge.net/downloads.html </li></ul><ul><li>Download 2007-05-17-jenademo.rar from this site and extract it in your directory (optional) </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  24. 24. Download Jena http://yuhanaresearch.wordpress.com <ul><li>http://jena.sourceforge.net/downloads.html </li></ul>RDF JENA Installing and Running Jena
  25. 25. Create New Java Project in Eclipse <ul><li>Open Eclipse </li></ul><ul><li>Create New Project by select </li></ul><ul><ul><li>File Menu  New  Project </li></ul></ul><ul><li>In the next dialog, choose Java  Java Project and click Next </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  26. 26. Define Project Name <ul><li>Write “JenaDemo” as a name, click Next button </li></ul><ul><li>Click Finish in the next dialog </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  27. 27. Create Source Folder <ul><li>Righ click on JenaDemo Project </li></ul><ul><li>Select New  Source Folder </li></ul><ul><li>given src as name and click Finish button </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  28. 28. Append Jena libraries to classpath <ul><li>Righ click on the project, choose Properties </li></ul><ul><li>Click “ Java Build Path ” section, choose “ library ” tab </li></ul><ul><li>Click “ Add External Library ” button, and find jena/lib source and choose all library , and click open </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  29. 29. Append Jena libraries to classpath <ul><li>Choose Order and Export Tab , check all the library by click “ Select All ” button </li></ul><ul><li>Make sure all Jena Library are checked , and click OK button </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  30. 30. Import Source Folder <ul><li>This step is optional if we want to import source folder from another folder </li></ul><ul><li>To do it, follow these steps: </li></ul><ul><ul><li>Suppose we have source folder that is extracted from 2007-05-17-jenademo.rar </li></ul></ul><ul><ul><li>Right click in src and choose “import” , choose General  File System and Click Next </li></ul></ul><ul><ul><li>Then Choose “browse” on Import dialog </li></ul></ul><ul><ul><li>Choose the folder where we put the source and click OK </li></ul></ul><ul><li>After done this part we can running jena API in Java for semantic web application </li></ul>http://yuhanaresearch.wordpress.com RDF JENA Installing and Running Jena
  31. 31. http://yuhanaresearch.wordpress.com <ul><ul><li>Right click in src and choose “import” </li></ul></ul>choose General  File System and click Next Then Choose “browse” on Import dialog <ul><ul><li>Choose the folder where we put the source and click OK </li></ul></ul>RDF JENA Installing and Running Jena
  32. 32. Thanks http://yuhanaresearch.wordpress.com

×