SWRL_XML jest częścią projektu heart. Dlatego też przed uruchomieniem SWRL_XML należy ściągnąć i zainstalować program heart.
Download swrl_xml.zip.
Plik swrl_xml.pl należy rozpakować do folderu, w którym jest zainstalowany heart (czyli tam gdzie m.in. plik heart.pl).
Należy załadować plik swrl_xml.pl. Spowoduje to automatyczne dołączenie plików heart.pl:
?- [swrl_xml].
Należy załadować plik z regułami, np. therm-rt.pl wpisująć:
?- [therm-rt].
Generowanie XML uzyskuje się przez:
?- swrl_xml_gen('output.txt'). % generowanie do pliku output.txt ?- swrl_xml_gen. % generowanie w konsoli.
Sprawdzona poprawność składniowa wygenerowanych plików przez http://www.w3.org/2001/03/webdata/xsv:
Validation was strict, starting with type [Anonymous] schemaLocs: http://www.w3.org/2003/11/swrlx -> http://www.ruleml.org/swrl/xsd/swrlx.xsd The schema(s) used for schema-validation had no errors No schema-validity problems were found in the target
Reguły w Heart (HMR):
xrule ms/1: [month in [january,february,december]] ==> [season set summer]. xrule ms/2: [month in [march,april,may]] ==> [season set autumn] :os. xrule ms/3: [month in [june,july,august]] ==> [season set winter] :os/3. xrule ms/4: [month in [9,10,11]] %in [september,october,november]] ==> [season set winter] :os.
xrule dt/1: [day in [monday,tuesday,wednesday,thursday,friday]] ==> [today set workday].%,
xrule dt/2: [day in [saturday,sunday]] ==> [today set weekend]. xrule th/1: [today eq workday, hour gt 17] ==> [operation set not_bizhours]. xrule th/2: [today eq weekend, hour eq any] ==> [operation set not_bizhours]. xrule th/3: [today eq workday, hour lt 9] ==> [operation set not_bizhours]. xrule th/4: [today eq workday, hour in [9 to 17]] ==> [operation set during_bizhours].
xrule os/1: [operation eq not_bizhours, season eq summer] ==> [therm_set set 27]. xrule os/2: [operation eq during_bizhours, season eq summer] ==> [therm_set set 24]. xrule os/3: [operation eq not_bizhours, season eq spring] ==> [therm_set set 15]. xrule os/4: [operation eq during_bizhours, season eq spring] ==> [therm_set set 20]. xrule os/5: [operation eq during_bizhours, season eq winter] ==> [therm_set set 18]. xrule os/6: [operation eq not_bizhours, season eq winter] ==> [therm_set set 14]. xrule os/7: [operation eq not_bizhours, season eq autumn] ==> [therm_set set 16]. xrule os/8: [operation eq during_bizhours, season eq autumn] ==> [therm_set set 20].
Translacja na SWRL: therm-rt-out.txt
Reguły w heart (HMR):
xrule ms/1: [month in [january,february,december], month in [ala,ma,kota]] ==> [season set summer]. xrule ms/2: [month in [march,april,may]] ==> [season set autumn] :os. xrule ms/3: [month in [june,july,august]] ==> [season set winter] **> [write(month)] :os/3. xrule ms/4: [month eq 5] ==> [season set winter] :os.
xrule dt/1: [day in [mon,tue,wed,thr,fri]] ==> [today set workday] **> [kot,ma,ale]. xrule dt/2: [day in [sat,sun]] ==> [today set weekend].
xrule th/1: [today eq workday, hour gt 17] ==> [operation set not_bizhours]. xrule th/2: [today eq weekend, hour eq any] ==> [operation set not_bizhours]. xrule th/3: [today eq workday, hour lt 9] ==> [operation set not_bizhours]. xrule th/4: [today eq workday, hour in [9 to 17]] ==> [operation set bizhours].
xrule os/1: [operation eq not_bizhours, season eq summer] ==> [therm_set set 27]. xrule os/2: [operation eq bizhours, season eq summer] ==> [therm_set set 24]. xrule os/3: [operation eq not_bizhours, season eq spring] ==> [therm_set set 15]. xrule os/4: [operation eq bizhours, season eq spring] ==> [therm_set set 20]. xrule os/5: [operation eq bizhours, season eq winter] ==> [therm_set set 18]. xrule os/6: [operation eq not_bizhours, season eq winter] ==> [therm_set set 14]. xrule os/7: [operation eq not_bizhours, season eq fall] ==> [therm_set set 16]. xrule os/8: [operation eq bizhours, season eq fall] ==> [therm_set set 20].
Translacja na SWRL:
<owlx:Individual owlx:name="ms"> <owlx:ObjectPropertyValue owlx:property="rules"> <owlx:Individual> <owlx:ObjectPropertyValue owlx:property="1"> <owlx:Individual owlx:name="#ms/1/1" /> </owlx:ObjectPropertyValue> <owlx:ObjectPropertyValue owlx:property="2"> <owlx:Individual owlx:name="#ms/2/1" /> </owlx:ObjectPropertyValue> (... reszta reguł ms/_/_ ...) </owlx:Individual> </owlx:ObjectPropertyValue> <owlx:ObjectPropertyValue owlx:property="link_from"> <owlx:Individual> <owlx:ObjectPropertyValue owlx:property="1"> <owlx:Individual owlx:name="#month" /> </owlx:ObjectPropertyValue> </owlx:Individual> </owlx:ObjectPropertyValue> <owlx:ObjectPropertyValue owlx:property="link_to"> <owlx:Individual> <owlx:ObjectPropertyValue owlx:property="1"> <owlx:Individual owlx:name="#season" /> </owlx:ObjectPropertyValue> </owlx:Individual> </owlx:ObjectPropertyValue> </owlx:Individual>
co odpowiadałoby zapisowi HMR:
xschm ms: [month] ==> [season].
Zaimportowane predykaty z Vardy z pliku varda_xtt.pl do generowanie XML posiadają buga. Predykat xml_tag_open/3 w niektórych przypadkach zwraca więcej niż 1 rezultat. Aktualna wersja obchodzi w pewien sposób ten błąd jednocześnie generując inny, mniej poważny (wybrałem „mniejsze zło” ).
W generowanym SWRL XML zamiast wszystkich zmiennych <ruleml:var> pojawia się tylko pierwsza z nich.
W podanych przykładach zamiast:
<ruleml:var>day</ruleml:var>
powinno być:
<ruleml:var>day</ruleml:var> <ruleml:var>hour</ruleml:var> <ruleml:var>today</ruleml:var> <ruleml:var>operation</ruleml:var> <ruleml:var>month</ruleml:var> <ruleml:var>season</ruleml:var> <ruleml:var>therm_set</ruleml:var>