Transformations of strings with SWRL

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

Transformations of strings with SWRL

mishima
Hello

I would like to know if using SWRL language is possible to make same string
trasformations like in ETL process.


I'm using Protege 3.4.5 OWL and have imported 2 Tables from 2 different DB
with DataMasterTab

Now the table are classes in this form:

C1 has 4 dataProperties A1, A2, A3, A4 where range is string and values are
"y" or '"n".

C2 has 1 dataProperties A5, where range is string and values area A1, A2, A3,
A4 concept.

C1 is Promotion_Lookup A1=hasHandOut, A2=hasRadio, A3=hasTelevision,
A4=hasEmail
C2 is Promotion A5=hasMediaType where mediatype value are HandOut, Radio, TV,
Email.
Example of A5 string are:
HandOut, Radio
Radio
HandOut, Radio, TV
Email
Radio, TV
TV
HandOut, TV, Email


Now i would like to divide A5 data properties in 4 data properties in form of
A1, A2, A3, A4, ''y'' or ''n''
else to merge A1, A2, A3, A4 into A5 data property but i need help.

I tried to use swrlb:substring to divide A5 but in every row, the third and
fourth args are variables, i can't write a general rule for all case.

I tried to use swrlb:stringEqualIgnoreCase to merge A1,A2,A3,A4 in A5 but i'm
not able to write a general rule, only specific, like:
Promotion_Lookup(?p) ^ hasHandOut(?p, ?h) ^ swrlb:string(?h, "y") ->
MyGeneralClass(?p) ^ hasMediaType(?p, "HandOut")  (not tested)

So my questions are:
Is this remodelling a good idea?
Can i follow one of the two ways? And if answer is yes, how?

Thank you very much and sorry for english
Gennaro

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Transformations of strings with SWRL

mishima
I think it's better divide media_type into 4 data properties.

So i resolve half part of the problem.

Promotion(?p) ^ hasMediaType(?p, ?m) ^ swrlb:contains(?m, "Radio") ->
MyNewClass(?p) ^ hasRadio(?p, "y")

I wrote 4 rules like this, one for Radio, Tv, HandOut and Email


Now i would like to insert "n" into individuals that not have Radio, Tv...

SWRL does not support Negative, there is another way to resolve this
problems?
I tryed swrlb:stringLenght(0, ?m) but not worked.
Don't work even swrlb:stringEqualIgnoreCase(?m, "")

Any ideals?

Thank you
Gennaro
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Transformations of strings with SWRL

Thomas Russ

On Apr 28, 2011, at 3:44 AM, Gennaro Mari wrote:

> I think it's better divide media_type into 4 data properties.
>
> So i resolve half part of the problem.
>
> Promotion(?p) ^ hasMediaType(?p, ?m) ^ swrlb:contains(?m, "Radio") ->
> MyNewClass(?p) ^ hasRadio(?p, "y")
>
> I wrote 4 rules like this, one for Radio, Tv, HandOut and Email
>
>
> Now i would like to insert "n" into individuals that not have Radio,  
> Tv...
>
> SWRL does not support Negative, there is another way to resolve this
> problems?
> I tryed swrlb:stringLenght(0, ?m) but not worked.
> Don't work even swrlb:stringEqualIgnoreCase(?m, "")
>
> Any ideals?

Not really.  SWRL is designed to preserve open world semantics, and  
you are trying to circumvent that by doing a closed world reasoning  
task.

In general, it would be more in keeping with OWL modeling to not do  
this sort of string manipulation, but rather to represent the items as  
actual objects, instances or class restrictions.  You could then write  
direct OWL restrictions that would allow the inference to take place  
directly in OWL.  That would look more like
    hasMediaType(___, Radio)
or
    some hasMedia Radio
for defining the restrictions and then writing classes that match:
    RadioPromotion == Promotion and (some hasMedia Radio)

On the other hand, if you are importing this information from another  
data source, perhaps this rule-based approach will work more easily  
than transforming the data during the import into Protege.

In any case, you won't be able to do the negative reasoning unless you  
have explicit values of hasMediaType that are the negated form.  From  
your use of "contains" it seems like there can be multiple types in  
the same string.  So the zero length test wouldn't really work either  
since the string "EMail, Tv" would not contain "Radio" but it also  
wouldn't be empty.

If you did go to the more OWL-like representation, then at least for  
the first variety you could fairly easily write a closure axiom for  
the media types.  For the second method, the closure would be a little  
more involved, but you also could write one.  The closure axioms would  
look something like
     hasMediaType only {Radio, EMail}
or
     hasMedia only (Radio or Email)


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03