You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Melanie Reiplinger <me...@dfki.de> on 2012/08/01 11:26:34 UTC

Re: rules endpoint

Hi Alessandro.

Am 16.07.2012 12:18, schrieb Alessandro Adamou:
> On 7/15/12 1:21 PM, Melanie Reiplinger wrote:
>> hmm, ok, so one could assume that it works analogously for the 
>> rules/find/recipes. But when doing
>>
>> curl -H "Accept: text/turtle" 
>> http://<stanbol>/rules/find/recipes?name=r2
>> or
>>  curl -H "Accept: text/turtle" 
>> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>>
>> I get a 404 Not Found.
>> (for a recipe named 'r2', created by
>> curl -i -X PUT 
>> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>> )
>>
>> what am I doing wrong?
>
> Nothing, except for assuming (with good reason) that it worked exactly 
> the same. The rules/find/recipes resource does not support the "name" 
> parameter at present, it only supports "description".
>
> This means that if you want a recipe to be found, it must have been 
> created with a comment, such as
>
> curl -i -X PUT 
> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2?description=Test%20recipe
>
> (not sure what happens with the URLencoded value for "description", 
> though)
>
> then
>
> curl -H "Accept: text/turtle" 
> http://lnv-89012.dfki.uni-sb.de:9001/rules/find/recipes?description=est
>
> Sorry for not finding this out earlier and misleading you.

Never mind, I'm here to test these things :-)
Fine, this one works.

>
>> Also: How do we then remove rules from a recipe, if we cannot address 
>> them simply by attaching their URI or name to the endpoint's URL?
>
> (again by checking the code) The recipe/rule path is currently in the 
> form
>
> /rules/recipe/{recipeId}?rule={ruleId}
>
> and the DELETE works the same way, depending on "rule" having a value 
> or not.
>
> It might be better to have something like
>
> /rules/recipe/{recipeId}/{ruleId}

ok so I tried this. I first created a recipe r2 and then uploaded a rule by

  curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y) 
-> has(?r, ?x, ?y)]" -F "description=transitivity" 
http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2

This works fine, by GET I can see that the rule has been integrated into 
the recipe. Now I try to delete:

   curl -i -X DELETE 
http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2?rule=transitivity

and I get '200 OK'. But when checking with GET, the 'transitivity' rule 
is still part of the r2 recipe. Seems it was not deleted. Also, 
submitting the very same rule twice to this recipe does not throw any 
error.

>
> but before that we should make sure that recipeId allows simple 
> non-URI identifiers and refactoring works with non-URIs (which maybe 
> now does).
>
>> And one more: For the refactoring functionality I didn't get very 
>> far. First thing I wanted to give some minimal toy RDF graph as an 
>> input and refactor via the RESTful Interface. This gives me the (not 
>> very informative) message:
>> "The site <stanbol> says: Error".
>> (in the form of an alert window). This error might be due to 
>> virtually anything. My toy example is
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <rdf:RDF
>>     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>>     xmlns:dbpedia="http://dbpedia.org/property/">
>>     <rdf:Description rdf:about="urn:example:person:ernie">
>>         <dbpedia:Person>Ernie</dbpedia:Person>
>>         <dbpedia:profession>Friend of Bert</dbpedia:profession>
>>     </rdf:Description>
>> </rdf:RDF>
>>
>> and I was hoping for something like an application of the 
>> "peopleProfessionRule" rule or something. (I already checked on 
>> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
>
> Here you're entering a realm I know even less, so I'm afraid I'm going 
> to need some more info.
>
> What does the rule look like? Remember with that RDF there (with 
> literal triples / datatype assertions in OWL) the rules must be of the 
> form values() instead of has()

ok, I will try to build my own recipe with rules that use the values() 
assertion.

>
> Did you use an HTML interface somewhere? Seems like the refactor 
> endpoint doesn't have one at the moment. Did you try it through the 
> tutorial in the /rules endpoint?

It doesn't have an interface??? I was trying on the /rules/ RESTful 
interface. You can load an RDF file and then click at 'refactor'. I 
thought that would do the job while only testing the default 
transformation patterns.

>
> What response did you get by issuing the equivalent request to 
> /refactor via curl?

Sorry, I didn't try that since it requires that I pass a recipe ID 
there, and I don't know by which ID these default rules go. So I'll 
report on that as soon as I have my own recipe to use for transformation.

Best,
melanie

>
> best
> -- Alessandro
>
>
>>> You can also ask for:
>>>
>>> text/turtle
>>> text/owl-manchester
>>> text/owl-functional
>>> application/owl+xml
>>> application/rdf+json
>>>
>>> Theoretically, it should also support
>>>
>>> application/json (JSON-LD)
>>> text/plain
>>>
>>> but I don't see a body writer registered with rule lists so it 
>>> didn't work for me.
>>>
>>> Best,
>>> Alessandro
>>>
>>>
>>>>> To check if it has been stored (and therefore parsed), you can do 
>>>>> a GET on
>>>>>
>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>
>>>>> requesting text/plain or some KR format such as
>>>>>
>>>>> text/turtle
>>>>> application/rdf+xml
>>>>> text/owl-manchester
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> Alessandro
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>



Re: rules endpoint

Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie,

On 8/1/12 11:26 AM, Melanie Reiplinger wrote:
> ok so I tried this. I first created a recipe r2 and then uploaded a
> rule by
>
>  curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y)
> -> has(?r, ?x, ?y)]" -F "description=transitivity"
> http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>
> This works fine, by GET I can see that the rule has been integrated
> into the recipe. Now I try to delete:
>
>   curl -i -X DELETE
> http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2?rule=transitivity
>
> and I get '200 OK'. But when checking with GET, the 'transitivity'
> rule is still part of the r2 recipe. Seems it was not deleted.

I haven't dug this as I'm not very rule store savvy, but it might be a 
bug in the Clerezza rule store. Maybe you could open a ticket on 
https://issues.apache.org/jira/browse/STANBOL ? (be sure to include 
Rules in the component field).

> Also, submitting the very same rule twice to this recipe does not
> throw any error.

 From what I can see, Rule does not override equals() or hashCode() so 
in general if two rules have the same body, they won't be recognized as 
equal unless their names are. But I guess you're right, it should at 
least return a 409 Conflict if the rule names matched.

>> Did you use an HTML interface somewhere? Seems like the refactor
>> endpoint doesn't have one at the moment. Did you try it through the
>> tutorial in the /rules endpoint?
>
> It doesn't have an interface??? I was trying on the /rules/ RESTful
> interface. You can load an RDF file and then click at 'refactor'. I
> thought that would do the job while only testing the default
> transformation patterns.

Yes that's the "hands-on" form, it's intended for the live tutorial but 
I'm sure a 'regular' GUI will be added too at some point. In the 
meantime, I guess you can use that form for testing.

What I meant is that literally the "[stanbol]/refactor" endpoint doesn't 
have a GUI yet (returns 500 on me), but that's okay because I think that 
endpoint should be moved to a sub-endpoint of /rules.

> Sorry, I didn't try that since it requires that I pass a recipe ID
> there, and I don't know by which ID these default rules go. So I'll
> report on that as soon as I have my own recipe to use for transformation.

I think it doesn't have one. It is also possible to refactor by passing 
the recipe in the payload without storing it with an ID. I think the 
tutorial does exactly that.

HTH
--alessandro


>>>> You can also ask for:
>>>>
>>>> text/turtle
>>>> text/owl-manchester
>>>> text/owl-functional
>>>> application/owl+xml
>>>> application/rdf+json
>>>>
>>>> Theoretically, it should also support
>>>>
>>>> application/json (JSON-LD)
>>>> text/plain
>>>>
>>>> but I don't see a body writer registered with rule lists so it
>>>> didn't work for me.
>>>>
>>>> Best,
>>>> Alessandro
>>>>
>>>>
>>>>>> To check if it has been stored (and therefore parsed), you can do
>>>>>> a GET on
>>>>>>
>>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>>
>>>>>> requesting text/plain or some KR format such as
>>>>>>
>>>>>> text/turtle
>>>>>> application/rdf+xml
>>>>>> text/owl-manchester
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> Alessandro
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>
>


-- 
M.Sc. Alessandro Adamou

Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy

Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy


"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)

Not sent from my iSnobTechDevice