Foaf for dummies

    You happened to learn what RDF is.
    You have read in my blog about some terrible FOAF, SIOC, SKOS, DOAP ...
    It is time to find out what it is and why I talked about RDF.

    Let's start


    FOAF
    F riend O f A F riend- the ontology of the description of a person (roughly speaking), or rather, personality. In short, the usual questionnaire that you filled out on the sites a million times. It contains information about the name, date of birth, work, contacts, acquaintances. It is the starting point in the Social Graph. Let's look in more detail? For greater understanding, you and I will come up with it, again, so that you understand the whole logic and see how everything is thought out here and why everything is so, and not that way. In addition, it will be convenient for people who do not read XML.

    We have a man (in this case, I gave myself up for an experiment, for the sake of science)
    So, who am I?

    Name : Nikolay Korobko
    Mail : admin@futuri.us
    Homepage : futuri.us
    Nickname : Nicholass
    Photo :img-fotki.yandex.ru/get/9/w88lf.8/0_9266_a7b0b5d8_L.jpg
    Interests :
    1. Web 3.0
    2. Semantic Network

    Personals :

    This is a distant but not a complete list, of course, but enough for understanding.
    Remember N3? let's try to apply?
    @prefix < xmlns.com/foaf/0.1/>
    Nikolay Korobko A: person
    Nikolay Korobko: hasMail
    Nikolay Korobko: hasHomepage < futuri.us>
    Nikolay Korobko: hasNik “Nicholass”
    Nikolay Korobko “hasPhoto < img-fotki.yandex.ru/get/9/w88lf.8/0_9266_a7b0b5d8_L.jpg>
    Nikolay Korobko: hasInterest“ Web 3.0 “
    Nikolai Korobko: hasInterest “Semantic Network”
    Nikolay Korobko: knows: people

    (in fact, this scheme does not work!)

    In a good way, then I have to create a similar list for my acquaintances. But this is a bit complicated, better readable for a person, but worse - for a car.
    For these purposes, FOAF was developed.
    Interlude : Namespaces Namespace
    (in XML) defines tags, attributes and their location relative to each other in a document.
    Take HTML for example. Lists. The namespace clearly states that
      may contain one or more
    • , as well as other elements. Or in the same namespace it is clearly said what the descendant is and what cannot contain .

    Without going into details of the namespace, we write down information about me (so far only about me) in the form of FOAF:
    Korobko NikolayNiholass

    Let's analyze line by line?

    This is where the connection of the very namespaces occurs. xmlns is nothing but an XML Name Space. We have included RDF, FOAF and RDF-schema.

    RDF in order to create an RDF document.
    FOAF is understandable for what :)
    RDF-schema is a format for RDF., Since FOAF is also an RDF document, the machine should check its format according to the RDF dictionary.

    This line indicates that we are describing a person. It is equivalent to “Nikolay Korobko A: person“. This is a container for describing a person. “Why is it needed, because we use FOAF, this is a description of a person !?” you will comment angrily, but everything is ahead, everything is thought out. look further.
    Korobko Nikolay

    By the way, I forgot to say that the prefix in the (foaf :) tag indicates which namespace we are taking it from, because there are matches, for example, in the Dublin Core (about it later) and in the HTML there is a title element.

    everything seems clear here. Name: Nikolay Korobko.
    Niholass

    Do you understand the general structure?

    First, we declared foaf: Person, in N3 we have a subject, the tag name will be a predicate, and the content will be an object. For instance. foaf: Person foaf: name “Nikolay Korobko”. rdf: resource is used to pass not a string, but a URI as an object.

    So, now we have assigned the person a name, mail (to protect against spam, it is sometimes encoded in sha1), the home page, nickname, and some description (foaf: depiction this field can contain any information about you, in this case the address of the photo).

    Remember that RDF has nesting? That is, the object may be another triple of values. In XML, this is shown simply by nesting tags.

    So, let's create interests for a person, for this we use the foaf: interest tag and put my interests in it. Now the triples will be such foaf: interest df: Description (rdf: about rdfs: label). That is, for Persons, There are interests: Interest: (URI and description of interest). We look:

    Like that. The same nesting is with acquaintances, but here we recall why we declare foaf: Person. After all, we are familiar with people, that is, the object will contain an embedded person. Another foaf: Person. I think many guessed how it would look:
    Misha KvakinRoman RybalchenkoCooluck

    It remains to put together the entire document.
    Korobko NikolayNiholassMisha KvakinRoman Rybalchenko

    Voila! Now, I hope everyone understands not only FOAF, but also the logic of compiling RDF documents in XML format.

    Д / З
    Try to create your own FOAF, and then check what happened. The links below show foaf-a-matic, it will help you with this.


    Materials taken from my blog .
    Write what else you will be interested to hear about in the “for dummies” section and I will try to write.

    Also popular now: