8
SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

Embed Size (px)

Citation preview

Page 1: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

SPARQL negationRules of the Semantic Web

Semantic MediaWiki

NSWI140

24.11.2010

Jan Dědek

Page 2: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

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#PREFIX owl: http://www.w3.org/2002/07/owl#PREFIX owl2xml: http://www.w3.org/2006/12/owl2-xml#PREFIX stud: http://www.semanticweb.org/ontologies/NSWI140/Study.owl#

SELECT ?name ?student ?year ?subjectWHERE{

?student a stud:Student;stud:hasName ?name;stud:hasStudyYear ?year.

OPTIONAL {

?student stud:hasSubject ?subject.?subject a stud:DatabseSubject.

}FILTER ( ?year > 1 )FILTER ( ! bound(?subject) )

}ORDER BY ?name

SPARQL negation - ! bound predicate

Page 3: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

Semantic WebStack

Latest “layercake” diagram

http://www.w3.org/2001/sw/layerCake.png

Page 4: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

Protege Rules Examples

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)

• 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

Page 5: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

Semantic MediaWiki (SMW) • 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

• 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)

• Inferencing:– Subcategories (MW), Subproperties, Equality of pages: (MW) redirects

• Not supported: Transitivity, Inverse properties, Domain and range restrictions, Number restrictions and functional properties

Page 6: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

SMW Editing• Categories

• Properties

• Data types– Custom units

• Semantic templates (MW -> SMW)

• Service links (links to online services: e.g. maps)

[[Category:Example category]]

[[property name::value]] [[Is capital of::Germany]] [[population::3,396,990]]

[[Has type::number]] Type:Temperature

[[provides service::online maps]]MediaWiki:Smw service online maps

IMDb|http://www.imdb.com/title/tt$1/

[[Corresponds to::1 W]][[Corresponds to::0.001 kW]][[Corresponds to::0.0013410220 hp]]

Page 7: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

SMW Search Selecting 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]]

[[Category:Actor]] [[height::>1.89m]] [[height::!1.89m]]

[[Address::~*Park Place*]]

[[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}}]]

Page 8: SPARQL negation Rules of the Semantic Web Semantic MediaWiki NSWI140 24.11.2010 Jan Dědek

SMW Search• 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 }}

[[Category:City]] [[has location country.population::+]]

?Population

?height#cm

{{#ask: [[Category:City]] [[located in::Germany]]| ?population

| ?area#km² = Size in km²}}

{{#show: Berlin | ?population}}