How to get SWRL Rules in java application?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get SWRL Rules in java application?

YP Protege
Hi all,

I want to map the data of ontology file to database.Now I have used "OWLOntologyManager" to get CLASS,OBJECT PROPERTY and so on,but I cannot get SWRL Rules in the owl file.

Which method should I use to get SWRL Rules?

Thanks in advance!

YP
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Martin O'Connor-2

Available for the latest Beta 23 Protege release:

https://github.com/protegeproject/swrlapi

There is also a plugin:

https://github.com/protegeproject/swrltab-plugin

Martin

> On Feb 23, 2016, at 6:33 PM, YP Protege <[hidden email]> wrote:
>
> Hi all,
>
> I want to map the data of ontology file to database.Now I have used
> "OWLOntologyManager" to get CLASS,OBJECT PROPERTY and so on,but I cannot get
> SWRL Rules in the owl file.
>
> Which method should I use to get SWRL Rules?
>
> Thanks in advance!
>
> YP
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-get-SWRL-Rules-in-java-application-tp4664541.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

YP Protege
Hi Martin,

Thank you for your advice,but the SWRLAPI may only edit SWRL Rules,I want get all rules in owl file.

Could I use OWLAPI?

YP
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Martin O'Connor-2

Thank you for your advice,but the SWRLAPI may only edit SWRL Rules,

Not sure what you mean by that. The SWRLAPI has an large array of components for working with SWRL rules.


I want get all rules in owl file.

Could I use OWLAPI?

If you just want to list the rules you could use the OWLAPI.

Martin



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

YP Protege
Hi Martin,

I just want list the rules and I want to use OWLAPI,but I cannot find the method.

Do you have some examples?

Thanks a lot.

YP
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Martin O'Connor-2

Take a look at the method listSWRLRules here: http://dior.ics.muni.cz/~makub/owl/

Martin

> On Feb 24, 2016, at 9:06 PM, YP Protege <[hidden email]> wrote:
>
> Hi Martin,
>
> I just want list the rules and I want to use OWLAPI,but I cannot find the
> method.
>
> Do you have some examples?
>
> Thanks a lot.
>
> YP
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-get-SWRL-Rules-in-java-application-tp4664541p4664560.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

YP Protege
Hi Martin,

I have listed all SWRL rules,and saved it in ORACLE database.The rules storge type is String.

Now I want to create a new ontology file, and add some SWRL rules in it according the information in database.

Could I use OWLAPI finish it?

Thank in advance.

YP
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Lorenz Buehmann
You should read some OWL API tutorials and have a look at the examples.
Moreover, I would suggest the OWL API mailing list for those questions.
As a hint, you should have a look at the OWLDataFactory::getSWRLRule and
OWLOntologyManager::addAxiom methods then.

Lorenz

> Hi Martin,
>
> I have listed all SWRL rules,and saved it in ORACLE database.The rules
> storge type is String.
>
> Now I want to create a new ontology file, and add some SWRL rules in it
> according the information in database.
>
> Could I use OWLAPI finish it?
>
> Thank in advance.
>
> YP
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-get-SWRL-Rules-in-java-application-tp4664541p4664679.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Martin O'Connor-2

Yes - the OWLAPI is sufficient for the types of manipulations you are doing on the SWRL rules.

The SWRLAPI (which used the OWLAPI) is needed for more advanced functionality.

Martin

> On Mar 7, 2016, at 12:05 AM, Lorenz B. <[hidden email]> wrote:
>
> You should read some OWL API tutorials and have a look at the examples. Moreover, I would suggest the OWL API mailing list for those questions. As a hint, you should have a look at the OWLDataFactory::getSWRLRule and OWLOntologyManager::addAxiom methods then.
>
> Lorenz
>
>> Hi Martin,
>>
>> I have listed all SWRL rules,and saved it in ORACLE database.The rules
>> storge type is String.
>>
>> Now I want to create a new ontology file, and add some SWRL rules in it
>> according the information in database.
>>
>> Could I use OWLAPI finish it?
>>
>> Thank in advance.
>>
>> YP
>>
>>
>>
>> --
>> View this message in context: http://protege-project.136.n4.nabble.com/How-to-get-SWRL-Rules-in-java-application-tp4664541p4664679.html
>> Sent from the Protege User mailing list archive at Nabble.com.
>> _______________________________________________
>> protege-user mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-user
>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

YP Protege
Hi all,

Thank you for you suggestion.I have solved the problem using the following method:

OWLClass clsA = factory.getOWLClass(IRI.create(BASE_URL + "#A"));
OWLClass clsB = factory.getOWLClass(IRI.create(BASE_URL + "#B"));
OWLClass clsC = factory.getOWLClass(IRI.create(BASE_URL + "#C"));
SWRLVariable var = factory.getSWRLVariable(IRI.create(BASE_URL + "#x"));
Set<SWRLClassAtom> body1 =    Collections.singleton(factory.getSWRLClassAtom(clsA, var));
Set<org.semanticweb.owlapi.model.SWRLClassAtom> body2 = Collections.singleton(factory.getSWRLClassAtom(clsC, var));
Set<SWRLClassAtom> head1 = Collections.singleton(factory.getSWRLClassAtom(clsB, var));
SWRLRule rule1 = factory.getSWRLRule(body1, head1);
manager.applyChange(new AddAxiom(ontology, rule1));
rule1 = factory.getSWRLRule(body2, head1);
manager.applyChange(new AddAxiom(ontology, rule1));


The console print:
B(?x) ← A(?x)
B(?x) ← C(?x)

But if I want to create some rules with more then 2 bodis,it like:
A(?x),B(?y),has_con(?x,?y)->has_sic(?x)

How to create it?

Thanks.

YP
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

Lorenz Buehmann
I don't understand the problem. First of all, you should understand that
a rule consist of only a single body and a single head only. Please read
some articles about rules first. Secondly, your body1 is a set of atoms,
thus, why not just put more than one atom into the set?

Lorenz

> Hi all,
>
> Thank you for you suggestion.I have solved the problem using the following
> method:
>
> /OWLClass clsA = factory.getOWLClass(IRI.create(BASE_URL + "#A"));
> OWLClass clsB = factory.getOWLClass(IRI.create(BASE_URL + "#B"));
> OWLClass clsC = factory.getOWLClass(IRI.create(BASE_URL + "#C"));
> SWRLVariable var = factory.getSWRLVariable(IRI.create(BASE_URL + "#x"));
> Set<SWRLClassAtom> body1 =
> Collections.singleton(factory.getSWRLClassAtom(clsA, var));
> Set<org.semanticweb.owlapi.model.SWRLClassAtom> body2 =
> Collections.singleton(factory.getSWRLClassAtom(clsC, var));
> Set<SWRLClassAtom> head1 =
> Collections.singleton(factory.getSWRLClassAtom(clsB, var));
> SWRLRule rule1 = factory.getSWRLRule(body1, head1);
> manager.applyChange(new AddAxiom(ontology, rule1));
> rule1 = factory.getSWRLRule(body2, head1);
> manager.applyChange(new AddAxiom(ontology, rule1));/
>
> The console print:
> B(?x) ← A(?x)
> B(?x) ← C(?x)
>
> But if I want to create some rules with more then 2 bodis,it like:
> A(?x),B(?y),has_con(?x,?y)->has_sic(?x)
>
> How to create it?
>
> Thanks.
>
> YP
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-get-SWRL-Rules-in-java-application-tp4664541p4664710.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to get SWRL Rules in java application?

YP Protege
Hi Lorenz,

Yes,you are right.I mean add more atoms,not more bodies.Sorry for that.

As you say,I add some atoms in the Set<SWRLAtom>,I have solved the problem.And I will read more articles about rules.

Thanks again.

YP