~~ODT~~ ====== SWRL_XML Intro ====== SWRL_XML jest częścią projektu [[hekate:heart|heart]]. Dlatego też przed uruchomieniem SWRL_XML należy ściągnąć i zainstalować program heart. ====== Pobierz ====== Download {{pl:miw:2009:miw09_swrltrans:projekt:swrl_xml.zip}}. ====== Wiadomości ====== * **29.05.2009** SWRL_XML release. ====== Uruchomienie ====== 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. ====== Przykłady translacji ====== 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 ===== therm-rt.pl ===== 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: {{:pl:miw:2009:miw09_swrltrans:projekt:therm-rt-out.txt|}} ===== examples-rt.pl ===== 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: {{:pl:miw:2009:miw09_swrltrans:projekt:examples1-rt-out.txt|}} ====== Propozycje rozszerzeń ====== * Wprowadzenie predykatów obliczeń matematycznych binarnych: sin, cos, divide, pow, ... * Obsługa nielicznych predykatów n-arnych: add, multiply, ... * Utworzenie sztucznych dla SWRL tabel regułowych np.: (... reszta reguł ms/_/_ ...) co odpowiadałoby zapisowi HMR: xschm ms: [month] ==> [season]. ====== Błędy ====== 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 pojawia się tylko pierwsza z nich. W podanych przykładach zamiast: day powinno być: day hour today operation month season therm_set