Coder Social home page Coder Social logo

Comments (7)

mdesalvo avatar mdesalvo commented on July 17, 2024 1

Hi @constnick,
I added two new methods in the Data object to fulfill the new use case:

  • DeclareNegativeIndividualType: to explicitly state that the given individual is not of the given class
OWLOntology ontology = new OWLOntology("ex:ont");
ontology.Model.ClassModel.DeclareClass(new RDFResource("ex:Cls"));
ontology.Data.DeclareIndividual(new RDFResource("ex:Idv"));
ontology.Data.DeclareNegativeIndividualType(ontology.Model, new RDFResource("ex:Idv"), new RDFResource("ex:Cls"));
  • CheckIsNegativeIndividualOf: to check if the given individual is explicitly not of the given class (which was your original question)
bool isNotIdvOfCls = ontology.Data.CheckIsNegativeIndividualOf(ontology.Model, new RDFResource("ex:Idv"), new RDFResource("ex:Cls"))

If this is desired, I'll release a new version with the code in the next few days.

Regards,
Marco

from owlsharp.

mdesalvo avatar mdesalvo commented on July 17, 2024

Hi constnick, given your individual I0 and your complement class C_C0, you can use:

bool isnotaC0 = myOntology.Data.CheckIsIndividualOf(myOntology.Model, I0, C_C0);

Regards,
Marco

from owlsharp.

constnick avatar constnick commented on July 17, 2024

It is checking for — is I0 explicitly belongs to C0 or not.
But I need to check, is I0 explicitly not belongs to C0.
For example in Turtle:

test:Man rdf:type owl:NamedIndividual ,
                   test:Human ,
                   [ rdf:type owl:Class ;
                     owl:complementOf test:Japanese
                   ] .

It means that Man is definitely known as not Japanese.
I need to check if there is such a declaration in the ontology.

from owlsharp.

mdesalvo avatar mdesalvo commented on July 17, 2024

Hi,
although the library is answering your need, I understand that you have a slightly different semantic to prove. This kind of check must be done at SPARQL level, where you have full power of controlling the raw RDF triples of the knowledge in such way:

//Get down to RDF/SPARQL level
RDFGraph ontologyGraph = ontology.ToRDFGraph(true);

//Build an ASK query detecting individuals of any complement class, constraining the answer to the "test:Man" individual and the "test:Japanese" class to be targeted
//Maybe it is more verbose than needed, containing pattern which may be omitted, but I prefer to remain formal
RDFAskQuery isNotJapaneseQuery = new RDFAskQuery()
    .AddPatternGroup(new RDFPatternGroup()
        .AddPattern(new RDFPattern(new RDFVariable("?IDV"), RDFVocabulary.RDF.TYPE, RDFVocabulary.OWL.NAMED_INDIVIDUAL))
        .AddPattern(new RDFPattern(new RDFVariable("?IDV"), RDFVocabulary.RDF.TYPE, new RDFVariable("?IDVCLS")))
        .AddPattern(new RDFPattern(new RDFVariable("?IDVCLS"), RDFVocabulary.RDF.TYPE, RDFVocabulary.OWL.CLASS))
        .AddPattern(new RDFPattern(new RDFVariable("?IDVCLS"), RDFVocabulary.OWL.COMPLEMENT_OF, new RDFVariable("?NOTIDVCLS")))
        .AddFilter(new RDFSameTermFilter(new RDFVariable("?IDV"), new RDFResource("test:Man")))
        .AddFilter(new RDFSameTermFilter(new RDFVariable("?NOTIDVCLS"), new RDFResource("test:Japanese"))));
RDFAskQueryResult isNotJapaneseQueryResult = isNotJapaneseQuery.ApplyToGraph(ontologyGraph);

Console.Write("test:Man IS NOT test:Japanese? " + isNotJapaneseQueryResult.AskResult);

Let me know if this fits yor needs.
Regards,
Marco

from owlsharp.

constnick avatar constnick commented on July 17, 2024

Yes, certainly I can do what I want with SPARQL, but it would be convenient to have such methods in an ontology object or its component.
By the way:
There are two kinds of "spo" or "spl" assertions: positive and negative.
And also there are the same two kinds of "type" statements.
For example, in Manchester syntax it expressed just with simple "not":

Individual: test:Man
    Types: 
        test:Human,
        not (test:Japanese)

May be it would be consistent to have symmetrical tools to work with negative "type" statements, just like with negative spo/spl assertions?

from owlsharp.

mdesalvo avatar mdesalvo commented on July 17, 2024

I didn't know the existence of the "negative type" statement. Maybe a OWL2 syntax which I didn't notice.

So, given an individual "ex:Idv" and a target class "ex:Cls" being the prohibited class, I'll figure how to add modeling support for this new construct:

ex:Idv rdf:type owl:NamedIndividual, 
                [ rdf:type owl:Class; owl:complementOf ex:Cls ] .

Regards,
Marco

from owlsharp.

constnick avatar constnick commented on July 17, 2024

Yes, I think that's what is needed, thanks!

from owlsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.