LogosLink Programmer's Guide · LogosLink Programmer's Interface version 2.0.1

Create Independent Ontology

The following example shows how to create an independent ontology and add some elements to it.

To execute this code, you will need a reference to the OntologyEngine package.

    using Incipit.LogosLink.OntologyEngine;

    //create ontology.
    var on = new Ontology("Test Ontology", "MyUserName");

    //add some categories.
    var caPerson = on.AddNewCategory("Person");
    var caPet = on.AddNewCategory("Pet");
    var caCat = on.AddNewCategory("Cat");
    caPet.AddSubType(caCat);

    //add properties to categories.
    var pyJob = caPerson.AddNewProperty("Job");
    var pyAge = caPet.AddNewProperty("Age");
    var pyBreed = caCat.AddNewProperty("Breed");

    //add an association.
    var anOwns = on.AddNewAssociation(caPerson, "Owns", caPet, "BelongsTo");

    //add some atoms and values.
    var atAlice = on.AddNewAtom(caPerson, "Alice");
    atAlice.AddNewValue(pyJob, "Accountant");
    var atValentina = on.AddNewAtom(caCat, "Valentina");
    atValentina.AddNewValue(pyAge, "5");
    atValentina.AddNewValue(pyBreed, "Siamese");

    //add a link.
    on.AddNewLink(anOwns, atAlice, atValentina);

In line 4, we create a new ontology named "Test Ontology".

In lines 7-9, we add categories for the Person, Pet and Cat concepts. Then, in line 10, we establish a sub-typing relationship so that cats are a subtype of pets.

In lines 13-15, we add properties to the categories. Note that the Age property, which is added to Pet, will be inherited by Cat by virtue of its sub-typing relationship.

In line 18, we add an association to capture the fact that people own pets.

Then, in lines 21-25, we add some atoms to represent one person, Alice, and one cat, Valentina. We also add values for Alice's job and Valentina's age and breed.

Finally, in line 28, we add a link to record the fact that Alice owns Valentina.


Contents distributed under a Creative Commons Attribution 4.0 International License · About · Terms of Use · Contact Us · last updated on 21/04/2025 16:01