80 likes | 369 Views
SPARQL negation Rules of the Semantic Web Semantic MediaWiki . NSWI140 24.11.2010 Jan D ědek. SPARQL negation - ! bound predicate. PREFIX rdf : http://www.w3.org/1999/02/22-rdf-syntax-ns# PREFIX rdfs : http://www.w3.org/2000/01/rdf-schema# PREFIX xsd : http://www.w3.org/2001/XMLSchema#
E N D
SPARQL negationRules of the Semantic WebSemantic MediaWiki NSWI140 24.11.2010 Jan Dědek
SPARQL negation - ! bound predicate PREFIXrdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# PREFIXrdfs: http://www.w3.org/2000/01/rdf-schema# PREFIXxsd: http://www.w3.org/2001/XMLSchema# PREFIXowl: http://www.w3.org/2002/07/owl# PREFIXowl2xml: http://www.w3.org/2006/12/owl2-xml# PREFIXstud: http://www.semanticweb.org/ontologies/NSWI140/Study.owl# SELECT?name?student?year?subject WHERE { ?studentastud:Student; stud:hasName?name; stud:hasStudyYear?year. OPTIONAL { ?studentstud:hasSubject?subject. ?subjectastud:DatabseSubject. } FILTER (?year > 1) FILTER ( ! bound(?subject) ) } ORDERBY?name
Semantic WebStackLatest “layercake” diagram http://www.w3.org/2001/sw/layerCake.png
Protege Rules Examples • SWRL - Semantic Web Rule Language • Rules saved as part of ontology • Increasing tool support: Bossam, R2ML, Hoolet, Pellet, KAON2, RacerPro • SWRLTab - Protégé 3, RulesView - Protégé 4 (Ontology views) http://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf Student(?s) , hasStudyYear(?s, ?y) , greaterThan(?y, "2"^^integer) -> Senior(?s) Room(?r) , hasName(?r, ?n) , startsWith(?n, "S") ->RoomMalaStrana(?r) Person(?p), hasSalaryInCZK(?p, ?czk), multiply(?eur, 24.7, ?czk) -> hasSalaryInEUR(?p, ?eur)
Semantic MediaWiki (SMW) • Search • Selecting pages • Categories and property values • wildcards and comparators, not equal, like (regexp) • Distance queries • Unions • Subqueries and property chains • Templates and variables • Sorting results • Displaying information • Special:Ask, inline queries • Printing: property values, categories • Display format: Plain, types • Concepts (stored queries) • Inline queries: #ask, #show, Exporting query results: RSS, etc. • Query settings (strict comparators) • Editing • Categories (MW) • Properties (named links & values) • Data types • Custom units • Semantic templates (MW -> SMW) • Service links (links to online services: e.g. maps) • Semantic Web • RDF export • Reusing vocabulary from external ontologies • Importing ontologies • SPARQL query service • Inferencing: • Subcategories (MW), Subproperties, Equality of pages: (MW) redirects • Not supported: Transitivity, Inverse properties, Domain and range restrictions, Number restrictions and functional properties
SMW Editing [[Category:Example category]] • Categories • Properties • Data types • Custom units • Semantic templates (MW -> SMW) • Service links (links to online services: e.g. maps) [[property name::value]] [[Is capital of::Germany]] [[population::3,396,990]] [[Has type::number]] Type:Temperature [[Corresponds to::1 W]] [[Corresponds to::0.001 kW]] [[Corresponds to::0.0013410220 hp]] IMDb|http://www.imdb.com/title/tt$1/ MediaWiki:Smw service online maps [[provides service::online maps]]
SMW SearchSelecting pages • Categories and property values • wildcards and comparators, not equal, like (regexp) • Distance queries • Unions • disjunctions in values • Subqueries and property chains • Templates and variables [[Category:Actor]] [[born in::Boston]] [[height::180cm]] [[Address::~*Park Place*]] [[Category:Actor]] [[height::>1.89m]] [[height::!1.89m]] [[born in::Boston]] OR [[born in::New York]] [[Category:Musical actor||Theatre actor]] [[Category:Actor]] [[born in:: <q>[[Category:City]] [[located in::Italy]]</q>]] [[Category:Event]] [[end date::>{{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY}}]]
SMW Search [[Category:City]] [[has location country.population::+]] • Sorting results • Displaying information • Special:Ask, inline queries • Printing: property values, categories • Display format: Plain, types • Concepts (stored queries) • Inline queries: #ask, #show,Exporting query results: RSS, etc. • Query settings (strict comparators) {{#ask: [[Category:City]] |?Average rainy days |?Located in=Country |sort=Located in,Average rainy days |order=ASC,DESC }} ?Population ?height#cm {{#ask: [[Category:City]] [[located in::Germany]] | ?population | ?area#km² = Size in km² }} {{#show: Berlin | ?population}}