Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concat String but with space #23

Open
TalyaFernandez opened this issue Aug 27, 2016 · 22 comments
Open

Concat String but with space #23

TalyaFernandez opened this issue Aug 27, 2016 · 22 comments

Comments

@TalyaFernandez
Copy link

Good Morning;
I want to create an SWRL Builtin that allow me to concat String but also to preserve the space between these string
for example I have this Builtin
Person(?p)^hasname(?p,?n)^hassurname(?p,?s)^hasage(?p,?a)^cb:concat(?m,?n,?s,?a)->sqwrl:select(?m)
for example I have Person with name (Talya) surname (Fernandez) age (24) the (?m) variable should contains (Talya Fernandez 24). I think the concat function return to me (TalyaFernandez24)
I hope That my idea is clear and I hope that you can help
Thanks in advance

@csnyulas
Copy link
Member

Have you tried:
cb:concat(?m, ?n, " ", ?s, " ", ?a)
? I am not sure it works, as I haven't tested it, but I don't see why it
would not.

Csongor

On 08/27/2016 01:22 AM, TalyaFernandez wrote:

Good Morning;
I want to create an SWRL Builtin that allow me to concat String but
also to preserve the space between these string
for example I have this Builtin
Person(?p)^hasname(?p,?n)^hassurname(?p,?s)^hasage(?p,?a)^cb:concat(?m,?n,?s,?a)->sqwrl:select(?m)
for example I have Person with name (Talya) surname (Fernandez) age
(24) the (?m) variable should contains (Talya Fernandez 24). I think
the concat function return to me (TalyaFernandez24)
I hope That my idea is clear and I hope that you can help
Thanks in advance


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#23, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ACU_VoLKvDIHpBGngiR3qdL2oWgmHgNAks5qj_PIgaJpZM4Jupa2.

@TalyaFernandez
Copy link
Author

Thank you,
I will try with it.
when I try to bind result in the first argument I got an error that I don't know where is the problem.
in this code arguments.get(resultArgNumber).setResult(createDataValueArgument(opResult));
I got an error in setResult tha indicates The method setResult(SWRLLiteralBuiltInArgument) is undefined for the type SWRLBuiltInArgument
and as a proposed result "Add cast to method receiver"

@martinjoconnor
Copy link
Member

martinjoconnor commented Aug 27, 2016

Make sure you are using the latests 1.1.1 release of the SWRLAPI. There is no createDataValueArgument in the current release of the SWRLAPI. (The Protege 3 version had a method of that name.)

See:

https://github.com/protegeproject/swrlapi/wiki/SWRLBuiltInBridge#assigning-values-to-built-in-arguments

@TalyaFernandez
Copy link
Author

Good Day
I download the last version of SWRLAPI and I use it but I still have the same error. I'm using Protege 5
Sir Martin, I use this link and I find this code that allow to bind result into variable
In fact, I don't well understand your message

There is no createDataValueArgument in the current release of the SWRLAPI. (The Protege 3 version had a method of that name.)

should I use Protege 3?

@martinjoconnor
Copy link
Member

You should use the latest version.

The link above has an example of binding a result to a variable.

...
// Bind the result to the first argument
arguments.get(resultArgNumber).setResult(createLiteralBuiltInArgument(opResult));
...

@TalyaFernandez
Copy link
Author

Hello Sir and Thank you
Sir, if you read my previous message I say that I use the latest version and aslo I use this code
but I still have the same problem that indicates

The method setResult(SWRLLiteralBuiltInArgument) is undefined for the type SWRLBuiltInArgument

Really I don't know what's the problem

@martinjoconnor
Copy link
Member

Ooops - my mistake. The documentation is outdated. I have now updated it.

// Bind the result to the first argument (which is unbound so must be a variable)
SWRLVariableBuiltInArgument resultArgument = arguments.get(resultArgNumber).asVariable();
resultArgument.setBuiltInResult(createLiteralBuiltInArgument(opResult));

Let me know if that works.

@TalyaFernandez
Copy link
Author

Ok
Thanks Sir
I was very stressed and now feeling relaxed
I wait your response from 8 hours 😀😀😀
Thanks
also me I will try with it
:)

2016-08-29 0:49 GMT+01:00 martinjoconnor [email protected]:

Ooops - my mistake. The documentation is outdated. I have now updated it.

// Bind the result to the first argument (which is unbound so must be a variable)
SWRLVariableBuiltInArgument resultArgument = arguments.get(resultArgNumber).asVariable();
resultArgument.setBuiltInResult(createLiteralBuiltInArgument(opResult));

Let me know if that works.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#23 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AUShtNAMAyHsc3oFGXBXNz0lUdBH_GJqks5qkh6JgaJpZM4Jupa2
.

@TalyaFernandez
Copy link
Author

Hello again,
The function that allow to bind the result to the first argument does not give any result.
In fact as I tell you in the first of this discussion that I want to create a built-in that allow me to concat different argument and return the result in the first argument. I try to verify this rule with an sqwrl rule that show me the result.
for example
Peerson(?p)^hasname(?p,?n)^hasage(?p,?a)^action:concat(?m,"Person", ?n, "has age", ?a)->sqwrl:select(?m).
In protege When I try to execute this rule I have some errors
Exception when running SQWRL query S2: error running SQWRL queries: error inserting asserted OWL axioms into Drools: [Error: invoker.invoke("S1", "action:concat", 0, false, new VPATH(), new BAVNs("m", "", "n", "", "a"), new UBA("m"), new L("Person", "xsd:string"), $n, new L("hasage", "xsd:string"), $a): unknown exception org.swrlapi.exceptions.UnresolvedSWRLBuiltInClassException thrown by built-in action:concat in rule S1: unresolved built-in class for prefix 'action' in rule 'S1': org.swrlapi.builtins.action.SWRLBuiltInLibraryImpl not found by swrltab-plugin [41]] [Near : {... invoker.invoke("S1", "action:c ....}] ^ [Line: 1, Column: 1]
I want to know at first if my idea is possible (the rule is it true)?
if it is the case why I don't have any result. In fact I want to add this result in another Dataproperty for Person (hasgeneralinformation) like
Person(?p) ^ hasname(?p, ?n) ^ hasage(?p, ?a) ^ action:concat(?m, "Person", ?n, "hasage", ?a) -> hasgeneralinformation(?p, ?m)
the idea is it possible?
the action:concat is the function Stringconcat.
Thanks a lot

@martinjoconnor
Copy link
Member

The approach makes sense.

Your built-in implementation class, however, is not being resolved at runtime.

Did you declare the package name properly?

See: https://github.com/protegeproject/swrlapi/wiki/SWRLBuiltInBridge#defining-built-ins-in-java

Note also:

protegeproject/protege#520

@TalyaFernandez
Copy link
Author

Hello Sir Martin,
Before asking this question, I try with different tries but I was failed.
so I try with: package org.swrlapi.builtins;
but it does not work, then I change it to
package org.swrlapi.builtins.action; but, unfortunatelly the problem is the same.
PS: to build my class I add all external Jar of SWRALPI and Protege5 plugins. is it true or the SWRLAPI is enough?
Thanks in advance
if you need for example my java project, my ontology any file that maybe help you to find where is the problem, I will sent it
Thank you

@martinjoconnor
Copy link
Member

The SWRLAPI Maven dependencies should be sufficient.

Create a public GitHub repo with a Maven POM and I can look at the project.

@TalyaFernandez
Copy link
Author

Hello Sir,
Thanks a lot for your Help
you find my project in this link
https://github.com/TalyaFernandez/Project
forgive me if I add my project in a wrong manner
honestly it the first time that I use Github
Thank you for your help
Good day

@TalyaFernandez
Copy link
Author

Hello Sir,
I'm very happy that you don't yet see my previous message because I think that I work in a wrong manner.
in the last I just build an ordinary java project and I add the plugin of SWRLAPI.
Now I create a maven project I add the necessary dependency, and I create the Jar file using (Custom->Goals->install) I have a jar file called custom-1.0-SNAPSHOT.
the plugin contain the version
The question is should I change the prefix custom that I define it in the ontology that conatin the builtin (concat as a subclass of SWRLBuiltin) to custom-1.0-SNAPSHOT?
or it is not important
Thanks for your help
Good day

@TalyaFernandez
Copy link
Author

Sir
I'm sorry if I send a lot of message in a court period but from more than a month I'm with this issue, and when I though that I resolve the problem I find another complicated error.
Even after building the maven project and create the Jar file, when I try to execute the builtin I find the same error.
I download my project action.rar in this link
https://github.com/TalyaFernandez/Project
PS: may be the problem on my project and may be is in the protege as what you post in
https://github.com/protegeproject/protege/issues/520
Thanks a lot for helping me to find and to correct this problem
Thanks Sir

@martinjoconnor
Copy link
Member

The repo should contain a fully buildable Java project - not RAR files.

I should be able to do something like:

git clone https://github.com/<user>/<repo>.git 
cd <repo>
mvn clean install

e.g., https://github.com/protegeproject/swrlapi-example

@TalyaFernandez
Copy link
Author

Hello Sir Martin,
Please check this link and you find my project.
https://github.com/TalyaFernandez/Project2
I hope that you can clone it now.
Thanks a lot for your help
Good day

2016-09-03 18:57 GMT+01:00 martinjoconnor [email protected]:

The repo should contain a fully buildable Java project - not RAR files.

I should be able to do something like:

git clone https://github.com//.git
cd
mvn clean install

e.g., https://github.com/protegeproject/swrlapi-example


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#23 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AUShtAxh843gFyWRdWwmaIz-X-JwyJZ0ks5qmbT0gaJpZM4Jupa2
.

@martinjoconnor
Copy link
Member

The project does not include the OWL file defining the built-in.

Note that you should not have an 'action' subdirectory here. The convention is to have the POM and source directories at the base repo level.

@TalyaFernandez
Copy link
Author

Hello Sir
forgive me it is the first time I use GitHub so I find several problems.
I try to change it but I have some problems
anyway, promise in the next time I will take your remark.
I hope that does not cause any problem for you when you will access to the code
I add the OWL file
Many Thanks for your help and for your patience with me
Good night

@TalyaFernandez
Copy link
Author

Hello Sir Martin
Please may I work directly with swrl.owl ontology. I import it and I add my own builtin as instance for swrl:builtin in the swrl.owl ontology and then to use it as swrb:builtin. I mean without creating another ontology that import the swrl ontology an the I create in this ontology my builtins because as you know I find a problem here
https://github.com/protegeproject/protege/issues/520

PS: Please check this link
https://github.com/TalyaFernandez/Project2 it contains the OWL file and the code of my class java
Thank you very much for your help
Good Day

@martinjoconnor
Copy link
Member

I will try to look at this over the weekend. Have many other deadlines at the moment.

@TalyaFernandez
Copy link
Author

OK Sir
Thanks a lot and Good Work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants