Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy...

17
Semantic Web Tools Semantic Web Tools Dipsy Kapoor Dipsy Kapoor

Transcript of Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy...

Page 1: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Semantic Web ToolsSemantic Web Tools

Dipsy KapoorDipsy Kapoor

Page 2: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

OutlineOutline

Piggy BankPiggy BankSolventSolventJenaJenaARQARQ

Page 3: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Semantic WebSemantic Web

““The The Semantic WebSemantic Web provides a common provides a common framework that allows framework that allows datadata to be shared to be shared and reused across application, enterprise, and reused across application, enterprise, and community boundariesand community boundaries”” --http://www.w3.org/2001/sw/http://www.w3.org/2001/sw/RDF & OWL RDF & OWL –– w3c standards for encoding w3c standards for encoding data and its semanticsdata and its semanticsThere isnThere isn’’t enough semantic web content t enough semantic web content on webon web

Page 4: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Piggy BankPiggy Bank

““Semantic Web BrowserSemantic Web Browser”” by people of the by people of the SIMILE project at MITSIMILE project at MITAvailable as a Firefox plugAvailable as a Firefox plug--in at in at http://simile.mit.edu/piggyhttp://simile.mit.edu/piggy--bank/bank/Can ingest RDF data directly from Can ingest RDF data directly from websites that contain meta information, websites that contain meta information, and can execute screenand can execute screen--scrapers to scrapers to extract content from normal websites and extract content from normal websites and then convert that data to RDFthen convert that data to RDF

Page 5: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Piggy BankPiggy Bank

Features of the browser:Features of the browser:Tagging Tagging –– Tag pages and individual itemsTag pages and individual itemsNavigation Navigation –– Selection on featuresSelection on featuresExport data in RDF/n3Export data in RDF/n3

Page 6: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

SolventSolvent

ScreenScreen--Scraper developed by the SIMILE Scraper developed by the SIMILE projectprojectInstalls as a Firefox plugInstalls as a Firefox plug--ininExtracts data and exports it as RDF/n3Extracts data and exports it as RDF/n3

Page 7: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Piggy Bank and Solvent DemoPiggy Bank and Solvent Demo

Page 8: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

JenaJena

A Semantic Web Framework that includes:A Semantic Web Framework that includes:A RDF API A RDF API Reading and writing RDF in RDF/XML, N3 and NReading and writing RDF in RDF/XML, N3 and N--Triples Triples An OWL API An OWL API InIn--memory and persistent storage memory and persistent storage SPARQL SPARQL query engine query engine

Documentation available at Documentation available at http://http://jena.sourceforge.net/documentation.htmljena.sourceforge.net/documentation.html

Page 9: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Using Jena API Using Jena API –– An ExampleAn Exampleimport import com.hp.hpl.jena.querycom.hp.hpl.jena.query.*;.*;import import com.hp.hpl.jena.rdf.modelcom.hp.hpl.jena.rdf.model.*;.*;

//Create a default model and add statements from a file //Create a default model and add statements from a file into itinto it

Model Model modelmodel = = ModelFactory.createDefaultModelModelFactory.createDefaultModel();();InputStreamInputStream in = new in = new FileInputStream(newFileInputStream(new File(filenameFile(filename));));model.read(in,nullmodel.read(in,null););

//Now can add statements to the model, can query the model //Now can add statements to the model, can query the model etcetc

//Write the model to a //Write the model to a PrintStreamPrintStream, in say N3 notation, in say N3 notationmodel.write(System.outmodel.write(System.out, , ““N3N3””); );

Page 10: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

ARQARQ

ARQ is JenaARQ is Jena’’s implementation of s implementation of SPARQL.SPARQL.ARQ documentation is available at: ARQ documentation is available at: http://http://jena.sourceforge.net/ARQ/documentjena.sourceforge.net/ARQ/documentation.htmlation.htmlCan write queries using the Jena Java API Can write queries using the Jena Java API or can write them in text files and execute or can write them in text files and execute them using them using ARQARQ’’ss command line utility.command line utility.

Page 11: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

SPARQL ExampleSPARQL ExamplePREFIX SM: <PREFIX SM: <http://simile.mit.edu/2005/05/ontologies/location#http://simile.mit.edu/2005/05/ontologies/location#>>

PREFIX DC: <PREFIX DC: <http://purl.org/dc/elements/1.1/http://purl.org/dc/elements/1.1/>>

SELECT DISTINCT ?title ?addressSELECT DISTINCT ?title ?address

FROM <sources/starbucks.n3>FROM <sources/starbucks.n3>

WHERE {WHERE {

?x ?x DC:titleDC:title ?title .?title .

?x ?x SM:addressSM:address ?address .?address .

}}

Page 12: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

SPARQL ExampleSPARQL ExamplePREFIX SM: <PREFIX SM: <http://simile.mit.edu/2005/05/ontologies/location#http://simile.mit.edu/2005/05/ontologies/location#>>PREFIX DC: <PREFIX DC: <http://purl.org/dc/elements/1.1/http://purl.org/dc/elements/1.1/>>

SELECT DISTINCT ?title ?addressSELECT DISTINCT ?title ?addressFROM <sources/starbucks.n3>FROM <sources/starbucks.n3>WHERE {WHERE {

?x ?x DC:titleDC:title ?title .?title .?x ?x SM:addressSM:address ?address .?address .FILTER (FILTER (regex(?addressregex(?address, , ““FigueroaFigueroa””, , ““ii””)))) ..

}}

regexregex is a Xis a X--Path function. Other functions available at Path function. Other functions available at hhttp://ttp://jena.sourceforge.net/ARQ/library.htmljena.sourceforge.net/ARQ/library.html

Page 13: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Querying multiple sources, Using Querying multiple sources, Using simple JOINsimple JOIN

PREFIX SM: <http://simile.mit.edu/2005/05/ontologies/location#>PREFIX SM: <http://simile.mit.edu/2005/05/ontologies/location#>PREFIX DC: <http://purl.org/dc/elements/1.1/>PREFIX DC: <http://purl.org/dc/elements/1.1/>PREFIX fn: <http://www.w3.org/2005/xpathPREFIX fn: <http://www.w3.org/2005/xpath--functions#> functions#>

SELECT DISTINCT ?title ?zip ?temperatureSELECT DISTINCT ?title ?zip ?temperatureFROM NAMED <sources/starbucks.n3>FROM NAMED <sources/starbucks.n3>FROM NAMED <sources/weather.n3>FROM NAMED <sources/weather.n3>WHERE {WHERE {

GRAPHGRAPH <sources/starbucks.n3> {<sources/starbucks.n3> {?x ?x DC:titleDC:title ?title .?title .?x ?x DC:zipcodeDC:zipcode ?zip?zip ..

} .} .GRAPHGRAPH <sources/weather.n3> {<sources/weather.n3> {

?y ?y DC:zipcodeDC:zipcode ?zip?zip ..?y ?y DC:temperatureDC:temperature ?temperature .?temperature .

} .} .}}

Page 14: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Example of InferenceExample of Inference

http://swui.semanticweb.org/swui.rdfhttp://swui.semanticweb.org/swui.rdfList of publications accepted at the SWUI List of publications accepted at the SWUI workshop , giving its title, author and workshop , giving its title, author and keywordskeywords

http://139.91.183.30:9090/RDF/VRP/Examhttp://139.91.183.30:9090/RDF/VRP/Examples/ACMples/ACM--CSS.rdfCSS.rdf

ACM computer Classification SystemACM computer Classification System

Page 15: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Software

Programming Languages

Software Engineering

Formal definitions and

Theoryinteroperability

semantics

Query: Get all papers published in SWUI that belong to the Software category

Data:X keyword "interoperability“Y keyword “semantics”

Solution:Without Inference: No solutionWith inference – X and Y

Page 16: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

Using InferenceUsing Inferenceimport import com.hp.hpl.jena.querycom.hp.hpl.jena.query.*;.*;import import com.hp.hpl.jena.rdf.modelcom.hp.hpl.jena.rdf.model.*;.*;

Model Model modelmodel = = ModelFactory.createDefaultModelModelFactory.createDefaultModel();();model.read(model.read(““http://swui.semanticweb.org/swui.rdfhttp://swui.semanticweb.org/swui.rdf””););model.read(model.read(““http://139.91.183.30:9090/RDF/VRP/Examples/ACMhttp://139.91.183.30:9090/RDF/VRP/Examples/ACM--

CSS.rdfCSS.rdf””););

InfModelInfModel infinf = = ModelFactory.ModelFactory.createRDFSModelcreateRDFSModel(model(model); ); //RDFS Model includes RDFS entailments like //RDFS Model includes RDFS entailments like subClassOfsubClassOfreasoningreasoning

Query Query queryquery = = QueryFactory.create(queryStringQueryFactory.create(queryString););QueryExecutionQueryExecution qeqe = = QueryExecutionFactory.create(queryQueryExecutionFactory.create(query, , infinf););ResultSetResultSet results = results = qe.execSelectqe.execSelect();();ResultSetFormatter.out(System.outResultSetFormatter.out(System.out, results, query);, results, query);

Page 17: Semantic Web Tools - Information Sciences Institute€¦ · Semantic Web Tools Author: dipsy Created Date: 12/6/2006 11:39:39 AM ...

LinksLinksPiggy Bank Piggy Bank –– http://simile.mit.edu/piggyhttp://simile.mit.edu/piggy--bank/bank/Solvent Solvent -- http://http://simile.mit.edusimile.mit.edu/solvent//solvent/Jena Documentation Jena Documentation --http://http://jena.sourceforge.net/documentation.htmljena.sourceforge.net/documentation.htmlARQ Documentation ARQ Documentation --http://http://jena.sourceforge.net/ARQ/documentation.jena.sourceforge.net/ARQ/documentation.htmlhtmlArticle by IBM on ARQ Article by IBM on ARQ -- http://wwwhttp://www--128.ibm.com/developerworks/xml/library/j128.ibm.com/developerworks/xml/library/j--sparql/sparql/