Edit

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

  1. Read and modify an ontology model use jena

    OntModel m = ModelFactory.createOntologyModel();
    m.read()
    m.listStatements()
    
  2. 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 example

    SELECT ?x
    WHERE { ?x  <http://www.w3.org/2001/vcard-rdf/3.0#FN>  "John Smith" }   
    
  3. 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 example rule1: (?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.
%23Head%20first%20Semantic%20network%0A@%28tech%7Csemantic%29%0A%0A%23%23%20what%20is%20semantic%0AA%20semantic%20network%20is%20a%20network%20that%20providing%20**resource**%20that%20machine%20readable.%20For%20examlple%2C%20%20in%20the%20html%20header%2C%20there%20is%20a%20%60meta%60%20part.%20that%20is%20semantic.%0A%0ASo%20there%20needs%20a%20language%20to%20describe%20the%20*resource*%20in%20the%20web.%20Here%20is%20the%20RDF%28resource%20define%20framework%29.%20and%20%60OWL%60%20is%20a%20specific%20%60RDF%60%28%20%u81F3%u5C11%u6211%u4EEC%u53EF%u4EE5%u8FD9%u4E48%u7406%u89E3%29%20%0A%0Athrough%20semantic%2C%20the%20compute%20program%20can%20surf%20the%20internet%20like%20our%20human%20being%2C%20they%20can%20leave%20a%20message%20to%20others.%20read%20blogs%20that%20others%20write.%20hahahaha.%20but%20all%20in%20a%20language%20that%20can%20not%20be%20read%20in%20our%20human%20beings.%0A%0A%23%23%20The%20Owl%20language%0AOwl%20langague%20is%20a%20kind%20of%20xml%20language.%20It%20have%20three%20parts%2C%20namley%2C%20**Class**%2C**Individual**%2C%20**Property**.%20%20The%20owl%20language%20conveys%20infomation%20in%20the%20form%2C%20%60subject%60%20%60predicate%60%20%60object%60%20forexample%2C%20%22I%20love%20you%22.%20%20%20in%20OWL%20it%20is%20called%20*triple*.%0A%0A%23%23%20Reasoning%0A%20Just%20like%20in%20our%20human%20language.%20from%20some%20infomation%20we%20can%20indicates%20other%20infomation%2C%20and%20both%20the%20information%20is%20expressed%20in%20language.%0A%20For%20example%2C%20%u6211%u7231%u4F60%uFF0C%u4F60%u7231%u4ED6%uFF0C%20then%2C%20%20%u4F60%u4EEC%u4E09%u4E2A%u662F%u4E09%u89D2%u5173%u7CFB%u3002%0A%20computer%20reasoning%20is%20just%20like%20that.%20from%20the%20infomation%20they%20get%20to%20indictate%20the%20infomation%20that%20haven%27t%20get.%0A%0A%23%23%20Realization%0AOne%20realization%20in%20java%20is%20the%20apache%20jena.%20%20It%20can%20read%20an%20ontology%2C%20make%20an%20ontology.%20and%20so%20on.%0A%0A%23%23%20How%20to%0A%0A1.%20Read%20and%20modify%20an%20ontology%20model%20use%20jena%0A%09%09%0A%09%09OntModel%20m%20%3D%20ModelFactory.createOntologyModel%28%29%3B%0A%09%09m.read%28%29%0A%20%20%20%20%20%20%20%20m.listStatements%28%29%0A%0A%0A2.%20%20Query%0A%0A%20like%20we%20use%20sql%20language%20to%20query%20a%20database%20for%20infomation%2C%20the%20semantic%20is%20querable.%0A%20It%20use%20a%20language%20called%20**SPARQL**%28QL%20may%20is%20the%20abbr.%20of%20%20query%20language%29.%20for%20example%0A%20%0A%0A%09%09SELECT%20%3Fx%0A%09%09WHERE%20%7B%20%3Fx%20%20%3Chttp%3A//www.w3.org/2001/vcard-rdf/3.0%23FN%3E%20%20%22John%20Smith%22%20%7D%09%0A%0A%0A3.%20Reasoning%0A%09%0A%20+%20a%20basic%20example%0A%20%0A%09%09%09String%20NS%20%3D%20%22urn%3Ax-hp-jena%3Aeg/%22%3B%0A%09%09%09//%20Build%20a%20trivial%20example%20data%20set%0A%09%09%09Model%20rdfsExample%20%3D%20ModelFactory.createDefaultModel%28%29%3B%0A%09%09%09Property%20p%20%3D%20rdfsExample.createProperty%28NS%2C%20%22p%22%29%3B%0A%09%09%09Property%20q%20%3D%20rdfsExample.createProperty%28NS%2C%20%22q%22%29%3B%0A%09%09%09rdfsExample.add%28p%2C%20RDFS.subPropertyOf%2C%20q%29%3B%0A%09%09%09rdfsExample.createResource%28NS+%22a%22%29.addProperty%28p%2C%20%22foo%22%29%3B%0A%09%09%09//%20create%20an%20inference%20model%20which%20performs%20RDFS%20inference%20%0A%09%09%09InfModel%20inf%20%3D%20ModelFactory.createRDFSModel%28rdfsExample%29%3B%20%20%0A%0A+%20rule%20baseed%20reasoning%0A%3E%20+%20How%20to%20write%20rules%0A%3E%20%20In%20jena%20the%20rules%20is%20write%20in%20it%27s%20own%20language%20the%20language%20is%20saying%20that%20on%20statements%20that%20already%20know%2C%20we%20can%20get%20new%20statements.%0A%3E%20%20It%20use%20the%20expresstion%20just%20like%20the%20**SPARQ**.%20%0A%3E%20%20For%20example%20%60%60%60rule1%3A%20%28%3Fa%20eg%3Ap%20%3Fb%29%20%28%3Fb%20eg%3Ap%20%3Fc%29%20-%3E%20%28%3Fa%20eg%3Ap%20%3Fc%29%60%60%60%20that%20is%20used%20to%20say%20%22if%20a%20p%20b%2C%20b%20p%20c%2C%20then%20a%20p%20c%22%20%20%20in%20the%20context%20the%20p%20may%20something%20like%20is%20the%20boss%20of%20.%20so%20the%20statement%20will%20be%20%20%22if%20a%20is%20the%20boss%20of%20b%2C%20and%20b%20is%20the%20boss%20of%20c%2C%20then%20a%20is%20the%20poss%20of%20c%22.%20haha.%0A%09%20%20%20%20