Adding Semantic Knowledge to an HTML Page Using SHOE
Once we have some ontologies to work with (see the tutorial here). We'll embed some semantic knowledge into our web page using SHOE. Let's take the following sample HTML page as an example.
This tells us:
Further, we've learned some interesting facts about Brun Hilda:
It so happens that we want to tell these exact things to intelligent agents and other knowledge-gatherers. To do this, we first need to tell the robot that we're using SHOE and uniquely define our document as an instance. An instance is similar to an "entity" as defined in the database world. However, we don't use the term "entity" because "entity" already in common use in another way in HTML and SGML. We begin by declaring that our page uses SHOE 1.0-compliant tags. To do this, in the HEAD section of our document, we add:
Instances and Keys
Before we can add semantic information to our web page, we need to define one or more instances, which are data objects which we will classify or relate to one another. It's paramount that instance be unique from one another--we wouldn't want two people writing instances with the same name. SHOE handles this by associating with each instance a unique key. SHOE has a standard protocol for coming up with a key for instances: base them on one (and only one) URL for the web page they're found on. For example, an instance about my dog Fido, found on some web page http://www.example.com/example.html, might have the key "http://www.example.com/example.html#fido". Or Richard Nixon's home page might contain a single instance with just his URL as key: "http://www.whitehouse.gov/trickydick.html". A web page might have many URLs that lead to it, so you'll have to pick which one you'll use as its official key and stick with that. This effectively guarantees that instance on other documents can't have the same keys as ones on your document, since no two documents can share the same URL (unless one went away and the other replaced it).
Using a single unique URL has an additional benefit: no one can pretend to be your document; if an intelligent agent comes across two documents who both claim to have the same key, the agent simply uses the key to look up which document's the real McCoy.
Let's assume that our document is located at http://www.cs.umd.edu/users/george/--that's the official URL of the document. On George's html page we'd like to add a SHOE instance talking about George (you can have as many instances on a page as you like). So for his key we'll use just his URL: "http://www.cs.umd.edu/users/george/". To declare the instance, we add to the page,
Using an Ontology
Next, before we can declare facts about our document, we need to tell the agent which ontology we're using to structure those facts. Without an ontology, agents would have no idea what, say, graduate-student means when we claim that that's what we (and our document) are. We'll use the CS Department ontology we partially described previously. Let's imagine that our ontology is stored at http://www.cs.umd.edu/projects/plus/SHOE/onts/cs.html and it's called cs-dept-ontology version 1.0. To indicate that we're using this particular ontology, we declare:
The PREFIX indicates that all references we make to elements declared in the cs-dept-ontology ontology will be prefixed with a "cs." prefix. We can use as many ontologies as we like, as long as each has a unique prefix.
Next, we'll classify or categorize the instance we're declaring on this web page--that is, we'll declare what the instance concerns. In SHOE, categorization is done using the CATEGORY tag in conjunction with one or more categories we've picked from the ontology we're using. In the body of the document, we'll add:
This says that this instance belongs to the classes or categories "GraduateStudent" and "ResearchAssistant" as defined in the ontology we've defined to use the "cs." prefix (i.e., cs-dept-ontology).
Next we'd like to tell web robots about relationships to other instances and data. We'll start with the relationships between the instance we're creating and some ordinary data: like our name and age.
This tells the robot that we have the relationship "name" as defined in the "cs" ontology with "George Stephanopolous", which is data of the type "STRING" (as defined in the ontology). It also says that we have the relationship "age" as defined in the "cs" ontology with "52", which is data of the type "NUMBER". Since it's highly likely that an instance will refer to itself in a lot of its relationship claims, SHOE provides the handy shortcut "me" to refer to the instance making the claim, as such:
Further, if the relation is binary (that is, it has only two argument positions), you can use "FROM" and "TO" instead of "1" and "2". The advantage of using "FROM" and "TO" is that SHOE then permits you to omit either the "FROM" or the "TO" argument if its value is the instance making the claim, which makes simple attribute claims even shorter. This is not permitted when you're using "1", "2", "3", etc. For example:
You can't mix and match these two ways of writing arguments (for example, POS=1 for one argument and POS=TO for the other).
Relationships don't have to be just between your instance and simple data; it's common to declare relationships with other instances, often on other web pages. For example, if we wanted to say that our graduate advisor was "John Smith", and John Smith declared an instance on his home page with a key of "http://www.cs.umd.edu/users/smith", we might say something like
Now, a little hypothetical situation: if there was no such thing as "cs.advisor" but there was a relationship between students and professors called, say, "cs.advisorOf" where the relationship pointed in the other direction (that is, between professors and students), then we could use this also, as in:
This is because the relation "advisorOf" is declared FROM professors TO students.
Some Relationship and Categorization Issues
This assumes that John Smith's home page uses HTML (instead of, say, PostScript), that it uses SHOE, that it declares http://www.cs.umd.edu/smith to be the key of the instance that represents him on his web page, and that John Smith has declared himself to be a Professor (in our ontology, advisor relationship is between Student and Professor). That's a lot of assumptions.
What if John Smith for some reason never actually declared an instance for himself on his home page? This could happen if his web page doesn't use SHOE, or doesn't use HTML, etc. In this case, the best we can do is point to his web page and let robots assume that the "key" is the URL of his web page as we've described. This isn't optimal because other people might do the same thing, but use different URLs; an agent might have a difficult time realizing they're pointing to the same thing. But it's the best we can do.
The other problem that crops up is: What if John Smith never declared himself to be a Professor? Well, we can make that claim for him. Agents would take our claim with a grain of salt (after all, he's not saying it), but at least it would help them understand in what context we're claiming that he's our advisor. So, we could say:
We don't have to categorize everyone we describe relationships with; this just shows that it's possible to describe relationship and categorizations that have nothing to do with our own instance.
Category declarations are similar to relationships in that the FOR is optional, just as arguments with FROM/TO were optional. If the FOR is missing, it's assumed to be the instance making the claim. So our original categorization of ourselves could have been either of:
Relationships with non-SHOE Documents
Now let's describe that paper we authored. The paper is a PostScript file, which as mentioned above can't use SHOE (of course) and therefore has never declared a unique key for itself. The best we can do is use a URL as its key. The publicationAuthor relationship is between publications and people, so we'll need to use a reverse relationship:
A Nested Instance
Finally, poor Brun Hilda, who only exists World-Wide-Web-wise as a mention on our web page, should get an instance all her own so we can declare facts about her. Brun Hilda will be sharing space on George's web page, so her instance needs a URL different from his instance, but also based on his URL. In SHOE, the accepted protocol for declaring keys for such "subordinate" instances is to use the basic URL, plus a hash mark ( # ), and then some small suffix that distinguishes her from other instances in our document. Let's pick http://www.cs.umd.edu/users/george/#BRUNHILDA as her unique key.
Instances begin with <INSTANCE ...> and end with </INSTANCE>. Notice that we've not declared George's </INSTANCE> tag yet, and yet we're ready to declare Brunhilda. If we're done with George, we can close his instance with </INSTANCE> and then start up the new Brunhilda instance. Or we can nest brunhilda inside George, that is, declare Brunhilda inside George's instance tags. It really doesn't matter much which way you do it, though nesting suggests that George's instance is in some sense "the parent of" or "in charge of" Brunhilda's instance. For the heck of it, let's nest. Now we can declare her instance. and use the techniques we discussed above to make claims about her inside this declaration...that her name is Brun Hilda, that she's a lecturer, and that she's 23, with something like:
Robots interpret any references within an INSTANCE declaration as pertaining to that declaration and not to an outside nesting instance. So the CATEGORY tag doesn't have to have an accompanying FOR tag indicating Brun Hilda.
Finishing UpTo indicate that we're done with George, we finish with
Claims versus Facts
Of course, if Brun Hilda got her own web page and declared an instance elsewhere, then our instance isn't of much use any more (it's her instance on her web page that's really the "Brun Hilda" instance. Nonetheless, we can still make claims about her (even false claims), like claims that she's a research group, or that she's 100 years old! It's important to realize that people can make whatever claims they want--that they're married to Madonna, or are the King of Spain, etc. Hence agents don't interpret claims as facts of knowledge, but as claims being made by a particular instance about itself or about other instances or data. This helps agents weed through the "likely true" claims and the "probably false" claims. In a distributed knowledge mechanisms like the World Wide Web, there's little getting around this; agents have no control over who makes what claims out there.
The Finished Product
So we're done marking up our web page. Let's see what it might look like: