Smurf
文章50
标签0
分类6
review1

review1

review1

1. XML Namespaces

1.1 Naming conflicts exist in different XML documents

1
2
3
4
5
6
XML document_1
<table>
<tr>
<td>Apples</td>
<td>Bananas</td></ tr>
</table>
1
2
3
4
5
6
XML document_2
<table>
<name>African Coffee Table</name>
<width>8G< /width>
<length>120</length>
< /table>

1.2 Solution : Adding prefixes as namespaces

1
2
3
4
5
6
7
XML document_1
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
1
2
3
4
5
6
XML document_2
< f:table>
<f:name >African Coffee lable</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>

image-20211103095753577

1.3 XML Namespace Syntax:

image-20211103095926352

  • URI 英文字符 IRI任何编码

2. RDF

  • the data model of Semantic Technologies and of the Semantic Web;

    • structures metadata about Web sites, pages, etc.:

      1. Page author, creator, publisher, editor,…

      2. 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.

image-20211103100203601

  • ARDF knowledge base: a directed labeled graph, i.e., Knowledge Graph

image-20211103100252591

2.1 RDF Triple (Statement)

image-20211103100511845

  • 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
2
3
prefix ex: <http://lexample.org/> .
ex: Chutneyex:hasIngredient "1lb green mango",
"1tsp. Cayenne pepper" .

image-20211103101325413

1
2
3
4
5
@prefix ex :<http://lexample.orgl> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:Chxtney ex:hasIngredient ex:ingredient1 .
ex:ingredient1 rdf:value ex:greenMango;
ex:amount "11b" .

image-20211103101445868

1
2
3
4
5
6
7
<rdf:Description rdf:about="http://example.org/Chutney">
<ex:hasIngredignt rdf:nodeID="id1"/>
</rdf:Description>
<rdf:Description rdf:nodeID="id1">
<ex:ingredient rdf:resource="http://example.org/greenMango"/>
<ex:amount>1lb</ex:amount>
</rdf:Description>
1
2
3
4
5
6
<rdf:Description rdf:about="http://example.org/Chutney">
<ex:hasIngredient rdf:parseType="Resource">
<ex:ingredient rdf:resource="http://example.org/greenMango"/>
<ex:amount>1lb</ex:amount>
</ex:hasIngredient>
</rdf:Description>

1
2
3
4
5
6
sw:John sw:is_a sw:professors ;
sw:has_name "John Doe”;
sw:has_id “987654321".
sw:John sw:is_a sw:professors .
sw:John sw:has_name “John Doe”.
sw:John sw:has_id 987654321.

image-20211103101839197

image-20211103101929849

image-20211103102051247

image-20211103102152197

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)

image-20211103102705413

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
2
ex:isMarriedTo rdfs:domain ex:Person.
ex:isMarriedTo rdfs:range 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?

image-20211103102937207

image-20211103103020644

3.5 Example: Reasoning with RDFS

image-20211103103054033

4. Constituents of a DL Knowledge Base

image-20211103103223481

4.1 Description Logic: ALC

  • ALC: the simplest DL

image-20211103151324905

  • complex concepts are defined as follows:
  1. ⊥ and T are concepts;

  2. For concepts C and D, ¬C, C⊓D, and C⊔D are concepts;

  3. 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

  1. 𝐴∀𝑅.𝐵
  2. (𝐴⨅𝐵)⨆𝐶
  3. (∃𝑅.𝐴)⨅𝐵
  4. ¬𝐴⨆𝐶¬
  • ×√√×

4.2.1 TBox:

  • For concepts C, D, a general concept inclusion (GCI) axiom has the form: C ⊑ D
    1. C≡D is an abbreviation for C ⊑ D and D ⊑ C.
    2. a TBox (terminological Box) consists of a set of GCIs.

image-20211103104518716

4.2.2 ABox:

  • an ALC ABox assertion can be of one of the following forms:
    1. C(a), called concept assertion
    2. 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

image-20211103105345883

image-20211103105546556

image-20211103105845638

image-20211103105705148

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

image-20211103110149746

image-20211103110229357

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)

image-20211103110341548

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 .

image-20211103110418373

  • TransE
    • For each triple , h is translated to t by r.

image-20211103110445417

image-20211103110509521

image-20211103110619357

Question

image-20211103110727550

image-20211103110742156

image-20211103110754239

7. RDB2RDF

Direct Mapping

image-20211103110951393

image-20211103111007885

image-20211103111048669

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)

image-20211103111316178

  • A triples map has three parts: - the input logical table
  • a subject map
  • several predicate-object maps (combining predicate and object maps).

image-20211103111519827

image-20211103111559499

image-20211103111707449

image-20211103111923676

image-20211103112014857

image-20211103112154023

image-20211103112229356

image-20211103112504423

image-20211103112610319

8. Exercise

  1. Please represent the following sentences graphically by means of blank nodes.
    Jonathon says cherries taste sweet.
    1月14日,国家药监局宣布酚酞片停止生产.

image-20211103114451839

  1. What can be inferred from the following triples using RDFS semantics?

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ex: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
    6
    ex: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 .
  2. 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.

image-20211103115803638

  1. 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

image-20211103120142002

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
2
3
_:x  rdf:type  owl:class  ;
owl:intersectionOf (sw:Man sw:Grandparent) ;
owl:equivalentClass sw:Grandpa .
  1. 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)},

  1. Given the following KG, use query rewriting on the query Person(x) (this query is used for checking whether x is a person) .

image-20211103152402394

  1. Given a relational database and RDF triples, please write corresponding R2RML triples maps which can map the given RDB to RDF.
  2. image-20211103152446128
1
2
3
4
5
6
7
8
9
10
<http://data.example.com/student/001> rdf:type ex:Student ;
ex:id "001" ;
ex:name "Wang" ;
ex:major <http://data.example.com/major/211> .
<http://data.example.com/student/002> rdf:type ex:Student ;
ex:id "002" ;
ex:name "Wu" .
<http://data.example.com/major/211> rdf:type ex:Major ;
ex:name "AI" .

本文作者:Smurf
本文链接:http://example.com/2021/08/15/knowledge%20engineering/8.%20Review/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可