Head first Semantic network
what is semantic
A semantic network is a network that providing resource that machine readable. For examlple, in the html header, there is a meta
part. that is semantic.
So there needs a language to describe the resource in the web. Here is the RDF(resource define framework). and OWL
is a specific RDF
( 至少我们可以这么理解)
through semantic, the compute program can surf the internet like our human being, they can leave a message to others. read blogs that others write. hahahaha. but all in a language that can not be read in our human beings.
The Owl language
Owl langague is a kind of xml language. It have three parts, namley, Class,Individual, Property. The owl language conveys infomation in the form, subject
predicate
object
forexample, “I love you". in OWL it is called triple.
Reasoning
Just like in our human language. from some infomation we can indicates other infomation, and both the information is expressed in language.
For example, 我爱你,你爱他, then, 你们三个是三角关系。
computer reasoning is just like that. from the infomation they get to indictate the infomation that haven’t get.
Realization
One realization in java is the apache jena. It can read an ontology, make an ontology. and so on.
How to
Read and modify an ontology model use jena
OntModel m = ModelFactory.createOntologyModel(); m.read() m.listStatements()
Query
like we use sql language to query a database for infomation, the semantic is querable.
It use a language called SPARQL(QL may is the abbr. of query language). for exampleSELECT ?x WHERE { ?x <http://www.w3.org/2001/vcard-rdf/3.0#FN> "John Smith" }
Reasoning
a basic example
String NS = "urn:x-hp-jena:eg/"; // Build a trivial example data set Model rdfsExample = ModelFactory.createDefaultModel(); Property p = rdfsExample.createProperty(NS, "p"); Property q = rdfsExample.createProperty(NS, "q"); rdfsExample.add(p, RDFS.subPropertyOf, q); rdfsExample.createResource(NS+"a").addProperty(p, "foo"); // create an inference model which performs RDFS inference InfModel inf = ModelFactory.createRDFSModel(rdfsExample);
rule baseed reasoning
- How to write rules
In jena the rules is write in it’s own language the language is saying that on statements that already know, we can get new statements.
It use the expresstion just like the SPARQ.
For examplerule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)
that is used to say “if a p b, b p c, then a p c" in the context the p may something like is the boss of . so the statement will be “if a is the boss of b, and b is the boss of c, then a is the poss of c". haha.
- How to write rules