Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Comp 318: Assignment 2     Comp 318: Assignment 2     Assignment 2: RDF/S and SPARQL The second practical assignment consists of two main tasks. The first assesses your knowledge of RDF/S as a modelling language. The second allows you to explore the practical use of the SPARQL query language and how to process SPARQL queries in Jena.  Jena is a Java framework for building Semantic Web and linked-data applications that provides a programmatic environment for RDF, RDFS, OWL and SPARQL. Task 1 Consider the following RDF/S graph: :Dare  rdf:type :song . :Doctor_Dee ref:type :opera . :composer :composed :musical_content . :song ref:type refs:Class . :opera rdf:type rdfs:Class . :Damon_Albarn rdf:type :musician ;                        :composed  :Dare ;                        :composed  :Doctor_Dee ;                        rdf:type :songwriter . 1.Describe the content of this document in natural language; 2.Draw the graph representation of the document; 3.Explain whether the following two statements can be represented in RDF/S and motivate your answer: a.Composers and songwriters are musicians; b.Composers compose operas and songwriters compose songs.   Task 2 Familiarise yourself with the  Music ontology. This ontology represents information on music styles and musicians.  The ontology is written in OWL expressed using its RDF/XML syntax. Write a Java program that uses JENA to: 1. Generate the list of class and object property names in the Music Ontology. Do not use SPARQL for this task but rather navigate the ontology in Jena and print out all the class names; 2. Process the following SPARQL queries: - Find the name of the artists who have been married to exactly two other artists;  - Write a query to find the name of Johnny Cash’s wife who is an artist; -  Find the URI for the group “Foo Fighters”; The output from your program should print the results for each of the queries above. Make sure the result of the queries is formatted appropriately, do not just cut and paste the RDF/XML syntax! In order to run the queries you can use the Talis SPARQL endpoint directly from Jena. Use ResultSetFormatter to pretty print your output Hints Before executing the queries through Jena in Task 2, test them out using the test SPARQL query point available here. In this way you can assess your query before inserting in the code. Please remember that even the smallest syntax error will cause a SPARQL query to return no results. The code to execute a query against a specific dataset should resemble the following lines: String service = "http://api.talis.com/stores/bbc-backstage/services/sparql"; Query q = QueryFactory.create(query, Syntax.syntaxARQ); QueryExecution qe = QueryExecutionFactory.sparqlService(service, q); Assignment Submission Assignments should be handed in electronically through the departmental coursework submission system.  For technical problems with the submission site please email either Dr. Tamma or Mr Shield. When submitting, check that you have adhered to the following list: 1. All of your code is contained in a single file. DO NOT use more than one file. The file's name MUST be 'OntologyQuery.java' (capital O and Q; lower-case everything else). This means that the main class name must also be 'OntologyQuery'. Save the file in a simple text file. 2. Your program should be written in Java, not some other language. 3. Your file should be a simple text file; it must not be compressed or encoded in any way. 4.Your program compiles and runs on the computer science department’s Windows system. If you have developed your code elsewhere (e.g. your home PC), port it to our system and perform a compile/check test before submission. It is your responsibility to check that you can log onto the department’s system well in advance of the submission deadline. 5.Your program does not bear undue resemblance to anybody else's! Electronic checks for code similarity will be performed on all submissions and instances of plagiarism will be severely dealt with. The rules on plagiarism and collusion are explicit: do not copy anything from anyone else’s code, do not let anyone else copy from your code and do not hand in 'jointly developed' solutions.  The only code you may make use of is that presented to you in lab exercises. 6.Submit the PDF file with the solution to your assignment task 1 and the text file containing your Java code in a zip file called “Assignment2-YourSurname.zip”. Use the compression programs provided on the systems in the labs. If your file cannot be unzipped it will not be marked!.   Useful resources: Slides on Jena http://www.csc.liv.ac.uk/~valli/Comp318/PDF/jena_slides.pdf Slides on SPARQL http://www.csc.liv.ac.uk/~valli/Comp318/PDF/ SPARQL specification http://www.w3.org/TR/rdf-sparql-query Jena SPARQL tutorial http://jena.sourceforge.net/ARQ/Tutorial/ Querying remote SPARQL services with ARQ http://jena.sourceforge.net/ARQ/sparql-remote.html A comprehensive JENA tutorial http://jena.sourceforge.net/tutorial/RDF_API/ A complete beginner's guide to starting a Jena project in Eclipse http://www.iandickinson.me.uk/articles/jena-eclipse-helloworld/ Marking Scheme: Below is the breakdown of the mark scheme for this assignment.  Each category will be judged on the correctness, efficiency and modularity of the code, as well as whether or not it compiles and produces the desired output. Task 1 - 20 marks Description in natural language = 5 marks; Graph = 5 marks; Whether the statements a and b translate in RDFS = 10 marks (5 marks each). Task 2 - 80 marks Definition of the correct SPARQL queries = 30 marks (10 marks each) Implementation of the correct call to the Talis SPARQL endpoint = 5 marks; List of all ontology classes and properties = 20 marks; Implementation of the Java program using JENA  = 15 marks; Output formatting, comments, correctness of results  and layout= 10 marks; Deadline 14/05/2012 at 4 pm This assignment contributes 10% to your overall mark for Comp 318.