review1
1. XML Namespaces
1.1 Naming conflicts exist in different XML documents
1 | XML document_1 |
1 | XML document_2 |
1.2 Solution : Adding prefixes as namespaces
1 | XML document_1 |
1 | XML document_2 |
1.3 XML Namespace Syntax:
- URI 英文字符 IRI任何编码
2. RDF
the data model of Semantic Technologies and of the Semantic Web;
structures metadata about Web sites, pages, etc.:
Page author, creator, publisher, editor,…
Data about them: email,phone, job,…
can be used for machine-readable data exchange;
is introduced in W3C Recommendation of 1999 (Version 1.O);- uses XML as main syntax for serialization.
- ARDF knowledge base: a directed labeled graph, i.e., Knowledge Graph
2.1 RDF Triple (Statement)
- Subjects: Resource or blank node
- Predicates: Resource
- Object: Resource, literal or blank node
Literals are:
- data values;
- encoded as strings;
- interpreted by datatypes;
- treated the same as strings without datatypes, called plain literal;
- A plain literal may have a language tag;
- Datatypes are not defined by RDF, but usually from XML Schema.
Typed Literals:
“Beantown3’^^xsd:string“
The Bay State”^^xsd:string
Plain literal and literals with language tags:
“France”‘France”@en
“France”‘@fr
“法国”@zh“
“Frankreich”@de
Equalities for Literals:
“0013^^xsd:integer =“13”^^xsd:integer
“123.0^^xsd:decimal= “00123”1^^xsd:integer (based on data type hierarchy)
Exercise
Does the datatype“德国”equals to“德国”@ zh ?
- 不一样
Blank node: unnamed resource or complex node
- The set of blank nodes, the set of all lRls (named resources)and the set of all literals are pairwise disjoint;
- Representation of blank nodes is syntax-dependent:underline+colon+ID (Turtle syntax):_:xyz,_:bn;
- The scope of the lD of a blank node is only the document towhich it belongs.
2.2 RDF: N-ary Relations
Example:
1 | prefix ex: <http://lexample.org/> . |
1 | @prefix ex :<http://lexample.orgl> . |
1 | <rdf:Description rdf:about="http://example.org/Chutney"> |
1 | <rdf:Description rdf:about="http://example.org/Chutney"> |
1 | sw:John sw:is_a sw:professors ; |
3. RDFS
- provides a data-modeling vocabulary for RDF data;
- is an extension of the basic RDF vocabulary;
- tries to provide consistent explanations for RDF data;- allows for specifying schema knowledge;
- Mothers are female
- Only persons write books
- is a part of the W3C Recommendation.
- Why do we need RDFS when there already exists XML Schema?
- XML Schema only defines syntax without semantics;
- XML Schema cannot reference “things”outside the document.
3.1 RDFS: Class and Instance
Given a triple:
1 | ex:SemanticWeb rdf:type ex:Textbook . |
which characterizes“Foundations of Semantic Web Technologies”as aninstance of the class “Textbook”.
- Aresource can be the member of more than one class
1 | ex:SemanticWeb rdf:type ex:Book . |
lnstance and class names cannot be distinguished syntactically with lRls..
RDFS helps explicitly state that a resource denotes a class:
1
ex:book rdf:type rdfs:Class .
rdfs:Class is the“class of all classes” .
3.2 Class Hierarchy (Taxonomy)
3.3 Property and Property Hierarchy
- Allow to state that a certain property can only be between things of a certain class:
- e.g. when a is married to b, then both a and b are Persons
1 | ex:isMarriedTo rdfs:domain ex:Person. |
- Datatypes can also be used for adding property restrictions:
1 | ex:hasAge rdfs:range xsd:nonNegativeInteger |
3.4 RDFS: Reification
- How to graphically represent a sentence by means of the blank node?
3.5 Example: Reasoning with RDFS
4. Constituents of a DL Knowledge Base
4.1 Description Logic: ALC
- ALC: the simplest DL
- complex concepts are defined as follows:
⊥ and T are concepts;
For concepts C and D, ¬C, C⊓D, and C⊔D are concepts;
For a role r and a concept C, ∃r.C and ∀r.C are concepts
- Example: Student ⊓ ∀attendsCourse.MasterCourse
- It describes the concept comprising : all students that attend only master courses.
4.2 Example: Are the following valid DL concepts
- 𝐴∀𝑅.𝐵
- (𝐴⨅𝐵)⨆𝐶
- (∃𝑅.𝐴)⨅𝐵
- ¬𝐴⨆𝐶¬
- ×√√×
4.2.1 TBox:
- For concepts C, D, a general concept inclusion (GCI) axiom has the form: C ⊑ D
- C≡D is an abbreviation for C ⊑ D and D ⊑ C.
- a TBox (terminological Box) consists of a set of GCIs.
4.2.2 ABox:
- an ALC ABox assertion can be of one of the following forms:
- C(a), called concept assertion
- r(a, b), called role assertion - an ABox consists of a set of ABox assertions
(1) Any student must attend at least one lecture.
Student ⊑ ∃Attend.Lecture
Students are those who attend at least one lecture?
- 不对的,因为这个are表示是完全相等的关系,但是后面那个concept的范围更大
(2) John is a brother of Mary.
Brother(John,Mary)
(3) Parents are exactly those who are mothers or fathers.
Parent ≡ Mother ⊔ Father
- A set of axioms (knowledge base) is satisfiable (or consistent) if it has a model.
- It is unsatisfiable (inconsistent) if it does not have a model.
- Inconsistency is often caused by modeling errors.
- Unicorn ⊑ Fictitious
- Unicorn ⊑ Animal
- Animal ⊑¬Fictitious
5. Deductive Reasoning: Backward Reasoning
- Backward reasoning (Backward chaining) is an inference method described colloquially as working backward from the goal.
- It is often used in entailment checking or query answering in KG.
- It uses the rules to rewrite the query in several ways and the initial query is entailed if a rewritten query maps to the initial facts.
Example1:
Rule: If you are human, then you are mortal.
Human(x)→Mortal(x)
Question: Is Socrates a mortal?
Solution: Check whether Mortal(Scorates) or Human(Scorates) is true.
5.1 Other Tasks in Logical Reasoning: Inconsistency Checking
Incoherent ontology: ontology with at least one unsatisfiable concept. Example: PhDStudent ⊑ Student, PhDStudent ⊑ Employee, Student ⊑Employee
Inconsistent ontology: ontology without a model. Example: PhDStudent ⊑ Student, PhDStudent ⊑ Employee, Student ⊑Employee, PhDStudent(John)
6. TransE: Take Relation as Translation
- For a fact (head, relation, tail), take the relation as a translation operator from the head to the tail .
- TransE
- For each triple
, h is translated to t by r.
- For each triple
Question
7. RDB2RDF
Direct Mapping
7.1 RDB2RDF: R2RML
- R2RML is a language for specifying mappings from relational to RDF data.
- A mapping takes as input a logical table, i.e.,
- a database table
- a database view (a virtual table collecting data from relational tables), or
- an SQL query (called an “R2RML view” because it is like an SQL view but does not modify the database)
- A triples map has three parts: - the input logical table
- a subject map
- several predicate-object maps (combining predicate and object maps).
8. Exercise
- Please represent the following sentences graphically by means of blank nodes.
Jonathon says cherries taste sweet.
1月14日,国家药监局宣布酚酞片停止生产.
What can be inferred from the following triples using RDFS semantics?
1
2
3
4
5
6
7
8
9ex:Undergraduate_student rdfs:subClassOf ex:Student .
ex:Postgraduate_student rdfs:subClassOf ex:Student .
ex:Professor rdfs:subClassOf ex: Academic_staff .
ex:Academic_staff rdfs:subClassOf ex:University_staff .
ex:Teach rdfs:domain ex:Academic_staff .
ex:Teach rdfs:range ex:Student .
ex:Supervise rdfs:domain ex:Professor .
ex:Supervise rdfs:range ex:Postgraduate_student .
ex:John ex:Supervise ex:Mary .1
2
3
4
5
6ex:Professor rdfs:subClassOf ex: University_staff .
ex:John rdf:type ex:Professor .
ex:Mary rdf:type ex:Postgraudate_student .
ex:John rdf:type ex:Academic_staff .
ex:John rdf:type ex:University_staff .
ex:Mary rdf:type ex:Student .Express the following sentences in Description Logics.
Li is a student of SEU.
Any person who is enrolled in a university is a college student.
- Are the following valid OWL axioms? If not, why? (class: A,B,C,D, role: R)
A⨅(B⨆ ∃R)
(∀R.A⨆B)⨅A
(A⨅B)¬C⨆D
5) Please write the corresponding RDF triples (in Turtle) of the following sentence: “Grandpas are the men who are grandparents”. Specific classes are defined in the namespace
http://semanticweb.org/. Prefixes are given as follows:
@prefix sw: http://semanticweb.org/ .
@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@prefix owl: http://www.w3.org/2002/07/owl# .
1 | _:x rdf:type owl:class ; |
- Give a model of the following ontology
Professor⊑FacultyMember,
Professor(Guilin Qi),
hasAffiliation(Guilin Qi, SEU),
StudentOf(Zhang, Guilin Qi)
A model:
∆={a,b,c}
I(Guilin Qi)=a, I(SEU)=b, I(Zhang)=c
I( Professor)={a}, I(FacultyMember)={a},
I(hasAffiliation)={(a,b)},
I(StudentOf)={(c,a)},
- Given the following KG, use query rewriting on the query Person(x) (this query is used for checking whether x is a person) .
- Given a relational database and RDF triples, please write corresponding R2RML triples maps which can map the given RDB to RDF.
1 | <http://data.example.com/student/001> rdf:type ex:Student ; |