Sunday 25 January 2015

FOAF vs sw

So, I was doing a little reading about FOAF, as it has some overlap with what I am trying to do. Anyway, here is a quote from that page:

Here's an example, a fragment from the mostly-fictional FOAF database. First we list some facts, then describe how the FOAF system makes it possible to explore the Web learning such things.
Dan lives in Zetland road, Bristol, UK with Libby and Craig. Dan's email address is danbri@w3.org. Libby's email address is libby.miller@bris.ac.uk. Craig's is craig@netgates.co.uk. Dan and Libby work for an organisation called "ILRT" whose website is at http://ilrt.org/. Craig works for "Netgates", an organisation whose website is at http://www.netgates.co.uk/. Craig's wife Liz lives in Bristol with Kathleen. Kathleen and Liz also work at "Netgates". Damian lives in London. Martin knows Craig, Damian, Dan and Libby quite well. Martin lives in Bristol and has an email address of m.l.poulter@bristol.ac.uk. (etc...)

Feeling in a minimalist word mood, here is how we would represent that knowledge in sw:
where-live |Dan> => |UK: Bristol: Zetland road>
lives-with |Dan> => |Libby> + |Craig>
email |Dan> => |email: danbri@w3.org>
works-for |Dan> => |organisation: ILRT>

email |Libby> => |email: libby.miller@bris.ac.uk>
works-for |Libby> => |organisation: ILRT>

email |Craig> => |email: craig@netgates.co.uk>
works-for |Craig> => |organisation: Netgates>
wife |Craig> => |Liz>

where-live |Liz> => |UK: Bristol>
lives-with |Liz> => |Kathleen>
works-for |Liz> => |organisation: Netgates>

works-for |Kathleen> => |organisation: Netgates>

website |organisation: ILRT> => |url: http://ilrt.org/>

website |organisation: Netgates> => |url: http://www.netgates.co.uk/>

where-live |Damian> => |UK: London>

knows-quite-well |Martin> => |Craig> + |Damian> + |Dan> + |Libby>
where-lives |Martin> => |UK: Bristol>
email |Martin> => |email: m.l.poulter@bristol.ac.uk>
Next example on that page:

- Find me today's web page recommendations made by people who work for Medical organisations
- Find me recent publications by people I've co-authored documents with
- Show me critiques of this web page, and the home pages of the author of that critique

"Find me today's web page recommendations made by people who work for Medical organisations"
-- first, we need to know a list of "medical organisations":
|medical organisations: list> => |med org: 1> + |med org: 2> + ...
-- then we need to know the employees of each of these:
employees |med org: 1> => |person 1> + |person: 2> + ...
employees |meg org: 2> => |person: 7> + |person 8> + ...
... and so on.
-- then we need to know "todays web page recommendations" for all those people:
todays-web-page-recommendations |person 1> => |url: a> + |url: b> + ...
...
todays-web-page-recommendations |person 15> => |url: p> + |url: q> + ...
-- then finally, we can ask our question:
todays-web-page-recommendations employees "" |medical organisations: list>

And to prove that works, I did a small test example in the console:
-- load in some sample knowledge:
|med org: list> => |med org 1> + |med org 2>
employees |med org 1> => |person 1>
employees |med org 2> => |person 2>
web-recommendation |person 1> => |url: a> + |url: b>
web-recommendation |person 2> => |url: p> + |url: q> + |url: r>

-- ask our question in the console:
sa: web-recommendation employees "" |med org: list>
|url: a> + |url: b> + |url: p> + |url: q> + |url: r>

"Find me recent publications by people I've co-authored documents with"
-- learn who we have co-authored with:
people-co-authored-with |me> => |Rob> + |Jack> + |Frank>
-- learn their recent publications:
recent-publications |Rob> => |paper: a> + |paper: b>
recent-publications |Jack> => |paper: j>
recent-publications |Frank> => |paper: s> + |paper: t> + |paper: x> + |paper: y> + |paper: z>

-- ask in the console:
sa: recent-publications people-co-authored-with |me>
|paper: a> + |paper: b> + |paper: j> + |paper: s> + |paper: t> + |paper: x> + |paper: y> + |paper: z>

"Show me critiques of this web page, and the home pages of the author of that critique"
-- learn critiques list:
list-of-critiques |this web page> => |critique 1> + |critique 2>
-- learn authors of those:
author |critique 1> => |Liz>
author |critique 2> => |Ron>
-- learn their homepages:
homepage |Liz> => |url: http://liz.org>
homepage |Ron> => |url: http://ron.org>

-- ask in the console:
sa: homepage author list-of-critiques |this web page>
|url: http://liz.org> + |url: http://ron.org>

Final example:

One page might tell use that "daniel.brickley@bristol.ac.uk works-at http://ilrt.org/". Another might tell use that "http://ilrt.org/ based-in bristol". On this basis, RDF-aware tools could conclude that the person whose email address is daniel.brickley@bristol.ac.uk works for an organisation based in Bristol.

-- learn this knowledge
works-at |daniel.brickley@bristol.ac.uk> => |http://ilrt.org/>
based-in |http://ilrt.org/> => |Bristol>

-- ask in the console:
sa: based-in works-at |daniel.brickley@bristol.ac.uk>
|Bristol>

And that is it for today! I hope a) the examples make sense, and b) I have shown a little of the power of the whole BKO scheme. Heh, and we haven't even used any function operators, this was all literal operators, and a big dose of linearity of literal operators.

I guess a couple of observations. 1) imagine how much harder this would be to do if we used standard neural net matrices and vectors. I think my symbolic notation is much simpler to use. 2) notice how close the questions asked in the console are to English. Again, another win for my notation.

Update: now we have pretty print table code, we can do things like:
sa: author-homepage |*> #=> homepage author |_self>
sa: table[critique,author,author-homepage] list-of-critiques |this web page>
+------------+--------+-----------------+
| critique   | author | author-homepage |
+------------+--------+-----------------+
| critique 1 | Liz    | http://liz.org  |
| critique 2 | Ron    | http://ron.org  |
+------------+--------+-----------------+

No comments:

Post a Comment