To jest stara wersja strony!


Opis

Tomasz Pałosz - tomekpalosz@o2.pl

translacja XTTML → R2ML 8-)

XTTML - format, który ma powstać na bazie XTT. XTT jest tabelarycznym sposobem reprezentacji wiedzy.

R2ML - jest obszernym i wygodnym zestawem zasad XMLowych pozwalającym na

  • wymianę zasad pomiędzy różnymi systemami i programami.
  • wzbogacanie ontologi za pomocą zasad.

Spotkania

08.03.04

TODO:

  • format reguł r2ml (Lukichev), prr (omg)

080318

080408

  • zgodność zrobionego r2ml z XSD (r2ml xmlschema!) xmlstarlet, inne
  • wizualizacja, werbalizacja
  • translacja do rif?
  • mozliwość uruchomienia na drools? See a VERY NICE tutorial on the group technologies. Login as guest, with key RMAI2007
  • jak atrybuty które są w r2ml mogą uprościć projekt therm, jak one się maja do atrybutów w rif

080422

  • therm osobna strona
  • minicases w r2ml
  • upload therm do drools + uruchom

080429

  • komplet plikow do R2ML w wiki, w tym xsd i translator → napisać do Giurca, Werner, cc: gjn
  • zestaw uwag po ang. co nie dziala w w.w., email jak wyzej
  • jak/czy można dostać urml z r2ml? patrz xmi!
  • jak zaimportować słownik do drools?

080520

  • translator (uakt. minicases GJN)
  • poczytać xtt
  • przemyśleć kwestię odwzorowania połączenia? mapowanie do invokeactionexpr?
  • mozliwość przejścia z r2ml prodrule do urml?

080603

  • sprawozd:
  • ?przejście xttml→xmi(urml) (prod rules)
  • ?przejście r2ml→xmi(urml) (prod rules)

Projekt

Translacja do RIF: W planach jest taki translator, ale w tej chwili nie ma go jeszcze zaimplementowanego. Atrybuty, z których korzystają oba formaty (RIF i R2ML) w podstawowej wersji są takie same tj. zgodne z rdf oraz xsd.

URML

URML dziedziczy z R2ML. Oba formaty są w sporej części zgodne (nie w pełni - prace nad pełną zgodnością trwają). Za pomocą programu Strelka można uzyskać kod R2ML'a z URML.

W związku z dziedziczeniem URML z R2ML mogą wystąpić problemy z przejściem w drugą stronę tj. z R2ML do URML.

W szczególnym przypadku reguły ProductionRule da się przekonwertować do URML.

Nie znalazłem informacji odnośnie konwertowanych wersji. URML wersja 0.2. R2ML wersja 0.5.

XTTML do URML (XMI)

To rozwiązanie byłoby wygodne, bo XTTML do URML do R2ML.

Sprawdzałem jak Strelka radzi sobie z wykorzystaniem InvokeActionExpression i nie da się tam zrobić wpisania w InvokeActionExpression takich formuł jak ja zaproponowałem. Invoke musi odnosić się do metody klasy.

Można ominąć ten problem robiąc metodę o takiej samej nazwie jak klasa (czyli konstruktor domyślny) i odnosić się do niego w InvokeActionExpression.

Znalazłem inne błędy w programie Strelka. Błędy w generowaniu kodu R2ML.

R2ML do URML (XMI)

Jest wykonalne. Niestety nie znalazłem żadnego translatora. Nawet zespół, który pracuje nad regułami R2ML nie pisał ich ręcznie tylko generował za pomocą Strelki. Opisują to w swoim postępowaniu przy tworzeniu reguł dla projektu Derby2005.

Możliwe jest jednak stworzenie takiego translatora. Sądzę, że byłoby wygodniejsze konwertowanie do URML (XMI dla Strelki) niż konwertowanie do R2ML, gdyż ze Strelki można potem wygenerować R2ML. Reguły nie są skomplikowane. Poniżej zamieszczam najbardziej okrojone reguły jakie udało mi się uzyskać dla prostego przykładu.

<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:URML="http:///URML.ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML">
  <notation:Diagram xmi:id="nD1" type="URML" element="element1" measurementUnit="Pixel">
    <styles xmi:type="notation:DiagramStyle" xmi:id="id1"/>
  </notation:Diagram>
  <uml:Package xmi:id="element1">
    <packagedElement xmi:type="uml:PrimitiveType" xmi:id="idString" name="String"/>
    <packagedElement xmi:type="uml:PrimitiveType" xmi:id="idBoolean" name="Boolean"/>
    <packagedElement xmi:type="uml:PrimitiveType" xmi:id="idInteger" name="Integer"/>
    <packagedElement xmi:type="uml:PrimitiveType" xmi:id="idFloat" name="Float"/>
    <packagedElement xmi:type="URML:ProductionRule" xmi:id="idPR" name="myPR1">
      <conditions xmi:type="URML:ClassificationAtom" xmi:id="idCA" condRule="idPR" filter="startDate-reservationDate>=5" clazz="idmyRental" classVariable="myRental"/>
      <producedActionExpr xmi:type="URML:AssignVariableActionExpr" xmi:id="idAE" rule="idPR" clazz="idmyRental" actionType="A" classVariable="myRental" statement="discount=10"/>
    </packagedElement>
    <packagedElement xmi:type="uml:Class" xmi:id="idmyRental" name="myRental">
      <ownedAttribute xmi:type="uml:Property" xmi:id="iddiscount" name="discount" type="idInteger" aggregation="composite"/>
      <ownedAttribute xmi:type="uml:Property" xmi:id="id_reservationDate" name="reservationDate" type="idInteger" aggregation="composite"/>
      <ownedAttribute xmi:type="uml:Property" xmi:id="id_startDate" name="startDate" type="idInteger" aggregation="composite"/>
    </packagedElement>
  </uml:Package>
</xmi:XMI>

Przy tak upakowanym kodzie istnieje problem odczytu takiego schematu w programie Strelka. Problem leży w zredukowanym fragmencie „notation:Diagram”. Efekt widoczny poniżej.

Tutaj kod R2ML wygenerowany na za pomocą Strelki z powyższego diagramu. Oczywiście kod w obu przypadkach jest identyczny.

<r2ml:RuleBase xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML" xmlns:soap="http://www.w3.org/2001/12/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <r2mlv:Vocabulary>
        <r2mlv:Class r2mlv:ID="myRental">
            <r2mlv:Attribute r2mlv:ID="discount">
                <r2mlv:range>
                    <r2mlv:Datatype r2mlv:ID="xs:integer"/>
                </r2mlv:range>
            </r2mlv:Attribute>
            <r2mlv:Attribute r2mlv:ID="reservationDate">
                <r2mlv:range>
                    <r2mlv:Datatype r2mlv:ID="xs:integer"/>
                </r2mlv:range>
            </r2mlv:Attribute>
            <r2mlv:Attribute r2mlv:ID="startDate">
                <r2mlv:range>
                    <r2mlv:Datatype r2mlv:ID="xs:integer"/>
                </r2mlv:range>
            </r2mlv:Attribute>
        </r2mlv:Class>
    </r2mlv:Vocabulary>
    <r2ml:ProductionRuleSet>
        <r2ml:ProductionRule r2ml:ruleID="myPR1">
            <r2ml:conditions>
                <r2ml:ObjectClassificationAtom r2ml:classID="myRental" r2ml:isNegated="false">
                    <r2ml:ObjectVariable r2ml:name="myRental"/>
                </r2ml:ObjectClassificationAtom>
                <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:greaterThanOrEqual" r2ml:isNegated="false" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
                    <r2ml:dataArguments>
                        <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="5"/>
                        <r2ml:DatatypeFunctionTerm r2ml:datatypeFunctionID="numeric-substract">
                            <r2ml:dataArguments>
                                <r2ml:AttributeFunctionTerm r2ml:attributeID="reservationDate">
                                    <r2ml:contextArgument>
                                        <r2ml:ObjectVariable r2ml:name="myRental" r2ml:classID="myRental"/>
                                    </r2ml:contextArgument>
                                </r2ml:AttributeFunctionTerm>
                                <r2ml:AttributeFunctionTerm r2ml:attributeID="startDate">
                                    <r2ml:contextArgument>
                                        <r2ml:ObjectVariable r2ml:name="myRental" r2ml:classID="myRental"/>
                                    </r2ml:contextArgument>
                                </r2ml:AttributeFunctionTerm>
                            </r2ml:dataArguments>
                        </r2ml:DatatypeFunctionTerm>
                    </r2ml:dataArguments>
                </r2ml:DatatypePredicateAtom>
            </r2ml:conditions>
            <r2ml:producedAction>
                <r2ml:AssignActionExpression r2ml:propertyID="discount">
                    <r2ml:contextArgument>
                        <r2ml:ObjectVariable r2ml:name="myRental"/>
                    </r2ml:contextArgument>
                    <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="10"/>
                </r2ml:AssignActionExpression>
            </r2ml:producedAction>
        </r2ml:ProductionRule>
    </r2ml:ProductionRuleSet>
</r2ml:RuleBase>

Odwzorowanie połączeń

Moja propozycja to dopisanie na końcu reguły, z której przechodzimy InvokeActionExpression.

Przykład 1: „Go to today of date”:

<r2ml:InvokeActionExpression r2ml:operationID="today">
  <r2ml:contextArgument>
    <r2ml:ObjectVariable r2ml:name="date" r2ml:classID="Date"/>
  </r2ml:contextArgument>
</r2ml:InvokeActionExpression>

Przykład 2: „Calculate the total payment of the purchase order”:

<r2ml:InvokeActionExpression r2ml:operationID="totalPayment">
  <r2ml:contextArgument>
    <r2ml:ObjectVariable r2ml:name="purchaseOrder" r2ml:classID="Order"/>
  </r2ml:contextArgument>
</r2ml:InvokeActionExpression>

Sprawozdanie

XTTML - format, który ma powstać na bazie XTT. XTT jest tabelarycznym sposobem reprezentacji wiedzy.

R2ML - jest obszernym i wygodnym zestawem zasad XMLowych pozwalającym na

  • wymianę zasad pomiędzy różnymi systemami i programami.
  • wzbogacanie ontologi za pomocą zasad.

Przykład

Rule 1: (AE_PTC04): If all of the following are true, then the car's Potential Theft Rating is moderate:

  • car's price is between $20000 and $45000.
  • car model is not on the list of „High Theft probability Auto”.

Kod opisujący słownik dla podanej reguły:

   <r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation=http://www.rewerse.net/I1/2006/R2ML 
                             http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd>
    <r2mlv:Vocabulary>
     <r2mlv:Class r2mlv:ID="Car">
      <r2mlv:Attribute r2mlv:ID="price">
       <r2mlv:range><r2mlv:Datatype r2mlv:ID="xs:integer"/></r2mlv:range>
      </r2mlv:Attribute>
      <r2mlv:Attribute r2mlv:ID="fabricationYear">
       <r2mlv:range><r2mlv:Datatype r2mlv:ID="xs:integer"/></r2mlv:range>
      </r2mlv:Attribute>
     </r2mlv:Class>
    </r2mlv:Vocabulary>
    <!-- ... -->
   </r2mlv:RuleBase>

Kod opisujący podaną regułę (R2ML):

  <r2ml:ProductionRule r2ml:ruleID="AE_PTC04">
    <r2ml:conditions>
      <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:lessThanOrEqual">
        <r2ml:dataArguments>
          <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="20000"/>
          <r2ml:AttributeFunctionTerm r2ml:attributeID="userv:Car.price">
            <r2ml:contextArgument>
              <r2ml:ObjectVariable r2ml:name="car" r2ml:classID="userv:Car"/>
            </r2ml:contextArgument>
          </r2ml:AttributeFunctionTerm>
        </r2ml:dataArguments>
      </r2ml:DatatypePredicateAtom>
      <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:lessThanOrEqual">
        <r2ml:dataArguments>
          <r2ml:AttributeFunctionTerm r2ml:attributeID="userv:Car.price">
            <r2ml:contextArgument>
              <r2ml:ObjectVariable r2ml:name="car" r2ml:classID="userv:Car"/>
            </r2ml:contextArgument>
          </r2ml:AttributeFunctionTerm>
          <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="45000"/>
        </r2ml:dataArguments>
      </r2ml:DatatypePredicateAtom>
      <r2ml:AttributionAtom r2ml:attributeID="userv:CarModel.highTheftProbability">
        <r2ml:subject>
          <r2ml:ObjectVariable r2ml:name="carModel" r2ml:classID="userv:CarModel"/>
        </r2ml:subject>
        <r2ml:dataValue>
          <r2ml:TypedLiteral r2ml:lexicalValue="false" r2ml:datatypeID="xs:boolean"/>
        </r2ml:dataValue>
      </r2ml:AttributionAtom>
    </r2ml:conditions>
    <r2ml:producedAction>
      <r2ml:AssignActionExpression r2ml:propertyID="userv:Car.potentialTheftRating">
        <r2ml:contextArgument>
          <r2ml:ObjectVariable r2ml:name="car" r2ml:classID="userv:Car"/>
        </r2ml:contextArgument>
        <r2ml:TypedLiteral r2ml:lexicalValue="moderate" r2ml:datatypeID="xs:string"/>
      </r2ml:AssignActionExpression>
    </r2ml:producedAction>
  </r2ml:ProductionRule>

Źródło przykładu: http://oxygen.informatik.tu-cottbus.de/rewerse-i1/?q=node/33

Spory przykład USserv Derby

Metamodel

Production Rule definition

A production rule is a statement of programming logic that specifies the execution of one or more actions in the case that its conditions are satisfied. Production rules therefore have an operational semantic (formalizing state changes, e.g., on the basis of a state transition system formalism). The effect of executing production rules may depend on the ordering of the rules, irrespective of whether such ordering is defined by the rule execution mechanism or the ordered representation of the rules. The production rule is typically represented as:

  if [condition] then [action-list]

Some implementations extend this definition to include an „else” construct as follows:

  if [condition] then [action-list] else [alternative-action-list]

although this form is not considered for PRR; all rules that contain an „else” statement can be reduced to the first form without an „else”, and the semantics for interpreting when „else” actions are executed may be complex in some Inferencing schemes. Note that this implies that a conversion from a PSM to a PIM might be complete but not reversible. Rules with „else” statements in a PSM would result in multiple PIM rules which could not then be translated back into the original rules. The new rules would be functionally equivalent, however.

Translacje

Dostępne są następujące translacje z użyciem języka R2ML: http://oxygen.informatik.tu-cottbus.de/rewerse-i1/?q=node/15

  • R2ML to F-Logic
  • F-LogicXML to R2ML
  • R2ML to Jess
  • R2ML to RuleML
  • RuleML to R2ML
  • R2ML to JenaRules
  • JenaRules to R2ML
  • SWRL to R2ML
  • R2ML to SWRL
  • R2ML to XMI
  • R2ML to OCL
  • OCL to R2ML

Thermostat

Thermostat

Dodatki

Możliwe rozszerzenia powyższego kodu:

1. znalazłem typ zmiennych r2mlv:dayOfWeek, który można wykorzystać

źródło: http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/r2mlv.xsd

2. time (czas) można określać jak wartość integer (określając czas jako parametr z przedziału 0-24):

      <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:lessThan">
        <r2ml:dataArguments>
          <r2ml:AttributeFunctionTerm r2ml:attributeID="time">
          </r2ml:AttributeFunctionTerm>
          <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="9"/>
        </r2ml:dataArguments>
      </r2ml:DatatypePredicateAtom>
      <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:greaterThan">
        <r2ml:dataArguments>
          <r2ml:AttributeFunctionTerm r2ml:attributeID="time">
          </r2ml:AttributeFunctionTerm>
          <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="17"/>
        </r2ml:dataArguments>
      </r2ml:DatatypePredicateAtom>

3. Podobnie jak z czasem można postąpić z thermostat_setting:

      <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:Equal">
        <r2ml:dataArguments>
          <r2ml:AttributeFunctionTerm r2ml:attributeID="thermostat_setting">
          </r2ml:AttributeFunctionTerm>
          <r2ml:TypedLiteral r2ml:datatypeID="xs:integer" r2ml:lexicalValue="20"/>
        </r2ml:dataArguments>
      </r2ml:DatatypePredicateAtom>

Drools

Dostęp do systemu Drools w IA.

Istnieje problem z translacją słowników (Vocabulary). Translator ucina wpisy <r2ml:Vocabulary>. Poza tym translator działa tylko na regułach typu „ProductionRule”. W mailu od dr Adriana Giurca otrzymałem potwierdzenie tej informacji. Cały translator oparty jest na wersji 0.4 R2ML'a i stąd moje problemy z nim. Otrzymałem także informację, że klasy napisane w javie powinny rozwiązać problem.

I jeszcze konkluzja: „However, testing your example I found some other errors in the translation :) I will come back with a new email soon.” Przypuszczałem, że translacja nie jest poprawna, ale bez dobrej znajomości JBOSS'a nie byłem w stanie tego uargumentować.

Przeglądnąłem przykład z biletami, zamiast Vocabulary klasy napisane są w JAVIE pod Eclipsem. Spróbuję na podstawie projektu example stworzyć podobny z klasą Date mającą początkowo atrybuty: day, today, później dodam: time, month, season.

Umieściłem regułę na drools. Umieściłem także na moim koncie skompilowane klasy wypisane poniżej. Nadal drools wyrzuca błąd. Przeszukałem definicji klas w tym przykładzie z biletami i nie znalazłem nigdzie.

Klasy potrzebne do działania reguł przekonwertowanych na JBOSS

package org.drools.examples;
 
 
    public static class Date {
 
        private String day;
 
        private String today;
        private int time;
        private String month;
	private String season;
 
 
 
        public Date() {
        }
 
 
 
        public String getDay() {
            return this.day;
        }
 
	public void setDay(final String day) {
            this.day = day;
        }
 
        public String getToday() {
            return this.today;
        }
 
        public void setToday(final String today) {
            this.today = today;
        }
 
	public String getMonth() {
            return this.month;
        }
 
	public void setMonth(final String month) {
            this.month = month;
        }
 
	public String getSeason() {
            return this.season;
        }
 
	public void setSeason(final String season) {
            this.season = season;
        }
 
	public int getTime() {
            return this.time;
        }
 
	public void setTime(final int time) {
            this.time = time;
        }
 
    }
 
 
    public static class Operation {
        private String kind;
 
 
        public Operation() {
        }
 
        public String getKind() {
            return this.kind;
        }
 
	public void setKind(final String kind) {
            this.kind = kind;
        }
    }
 
 
    public static class Thermostat {
        private String thermostat_setting;
 
 
        public Thermostat() {
        }
 
        public String getThermostat_setting() {
            return this.thermostat_setting;
        }
 
	public void setThermostat_setting(final String thermostat_setting) {
            this.thermostat_setting = thermostat_setting;
        }
    }

Link do przykładu kodu samochodów - dostęp wymaga hasła

Przykład kodu klas potrzebnych do drools

Dodałem te importy, które są w tym przykładzie i spróbowałem skompilować na borgu. Okazuje się, że borg nie posiada tych plików. Można stwierdzić na tej podstawie, że brakuje ich na serwerze.

Minicases

Zakładam, że InvokeActionExpression wywołuje reguły, które jako argument mają podany atrybut klasy. Jest jeszcze możliwość wpisania w InvokeActionExpression ID reguły, bez contextu. 1 przypadek przechodzi sprawdzenie xsd, ale 2 nie jest zgodny.

Bazując na poniższych przypadkach (minicases) można stwierdzić, że da się przekonwertować XTTML do R2ML. Niestety użyte rozwiązanie wykorzystujące InvokeActionExpression nie jest zgodne w pełni z regułami R2ML. To znaczy xmlstarlet najczęściej stwierdza poprawność reguł. Jednak vizualizer i verbalizer nie pokazują poprawnie skonstruowanych reguł.

restrictive behavior

Reguła: if X > 2 then Y = X

Efekt werbalizacji: If X is greater than 2 then X is equal to Y.

<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd">
 
 <r2mlv:Vocabulary> 
  <r2mlv:Attribute r2mlv:ID="X">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">1</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">2</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">3</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">4</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">5</r2mlv:Datatype>
      </r2mlv:range>
     </r2mlv:Attribute>
 </r2mlv:Vocabulary>
 
 
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:ruleID="restrictive_behavior">
   <r2ml:Documentation>
       <r2ml:RuleText r2ml:textFormat="plain">
            if X > 2 then Y = X
       </r2ml:RuleText>
   </r2ml:Documentation>
    <r2ml:conditions>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:greaterThan">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="X">
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="2" r2ml:datatypeID="xs:positiveInteger"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
    </r2ml:conditions>
 
    <r2ml:producedAction>
 
      <r2ml:AssignActionExpression r2ml:propertyID="Y">        
       <r2ml:value>
        <r2ml:TypedLiteral r2ml:lexicalValue="X" r2ml:datatypeID="xs:positiveInteger"/>
       </r2ml:value>
      </r2ml:AssignActionExpression>
 
    </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>
 
</r2ml:RuleBase>

restrictive behavior and multiple values

grade || nrfail       | grmean       | nrgrades    |
----------------------|-----------------------------
=2    || =count(grade)|              |             |
      ||              | =mean(grade) |=count(grade)|

Tej reguły najprawdopodobniej nie da się przedstawić za pomocą języka R2ML. Próbowałem wykorzystać globalną zmienną, która liczyłaby atomy/termy/obiekty, ale nie za bardzo jest możliwość iteracji po tych elementach.

restrictive behavior and multiple values cont

Reguła: if grade > 4 then grade = grade

Efekt werbalizacji: If grade is greater than 4 then grade is equal to grade.

Tutaj przyjmuję, że Grade jest klasa. Też nie do końca poprawne rozwiązanie.

<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd">
 
 <r2mlv:Vocabulary> 
   <r2mlv:Class r2mlv:ID="Grade"> 
    <r2mlv:Attribute r2mlv:ID="grade">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">2</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">3</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">4</r2mlv:Datatype>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger">5</r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 </r2mlv:Vocabulary>
 
 
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:ruleID="restrictive_behavior_and_multiple_values_cont">
   <r2ml:Documentation>
       <r2ml:RuleText r2ml:textFormat="plain">
            if grade > 4 then delete grade
       </r2ml:RuleText>
   </r2ml:Documentation>
    <r2ml:conditions>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:graterThan">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="grade">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="grade" r2ml:classID="Grade"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="4" r2ml:datatypeID="xs:positiveInteger"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
    </r2ml:conditions>
 
    <r2ml:producedAction>
 
      <r2ml:DeleteActionExpression r2ml:classID="">
        <r2ml:contextArgument>
          <r2ml:ObjectVariable r2ml:name="grade" r2ml:classID="Grade"/>
        </r2ml:contextArgument>
       </r2ml:DeleteActionExpression>
 
    </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>
 
</r2ml:RuleBase>

grouped attributes and multiple value operations

Efekt werbalizacji: If salary of employee in previous_year is less than 2000 then name of employee is a bonusname and salary of employee is equal to salary*1.1.

<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd">
 
 <r2mlv:Vocabulary> 
   <r2mlv:Class r2mlv:ID="Employee"> 
    <r2mlv:Attribute r2mlv:ID="name">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="salary">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 
   <r2mlv:Class r2mlv:ID="Bonusname"> 
    <r2mlv:Attribute r2mlv:ID="bonusname">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 
 </r2mlv:Vocabulary>
 
 
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:ruleID="grouped_attributes_and_multiple_value_operations">
   <r2ml:Documentation>
       <r2ml:RuleText r2ml:textFormat="plain">
            Increase salary by 10% for these employees who earn less than 2000. And store their names in bonusname attribute.
       </r2ml:RuleText>
   </r2ml:Documentation>
    <r2ml:conditions>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:lessThan">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="salary">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="employee" r2ml:classID="Employee"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="2000" r2ml:datatypeID="xs:positiveInteger"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
    </r2ml:conditions>
 
    <r2ml:producedAction>
 
     <r2ml:AssignActionExpression r2ml:propertyID="salary">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:classID="Employee" r2ml:name="employee" />
       </r2ml:contextArgument>         
       <r2ml:value>
        <r2ml:TypedLiteral r2ml:lexicalValue="1,1*salary" r2ml:datatypeID="xs:positiveInteger"/>
       </r2ml:value>
     </r2ml:AssignActionExpression>
 
     <r2ml:CreateActionExpression r2ml:propertyID="Bonusname">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="bonusname" />
       </r2ml:contextArgument>         
       <r2ml:DataSlot r2ml:attributeID="bonusname">
         <r2ml:AttributeFunctionTerm r2ml:attributeID="name">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="employee" r2ml:classID="Employee"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
       </r2ml:DataSlot>
     </r2ml:CreateActionExpression>
 
    </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>
 
</r2ml:RuleBase>

grouped attributes and assert

Efekt werbalizacji: If ename of Emplyee is any and esalary of Emplyee is any then do assign ename to name of employee.

<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd">
 
 <r2mlv:Vocabulary> 
   <r2mlv:Class r2mlv:ID="Employee"> 
    <r2mlv:Attribute r2mlv:ID="name">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="salary">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 
   <r2mlv:Class r2mlv:ID="eEmployee"> 
    <r2mlv:Attribute r2mlv:ID="ename">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="esalary">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:positiveInteger"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 </r2mlv:Vocabulary>
 
 
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:ruleID="grouped_attributes_and_assert">
   <r2ml:Documentation>
       <r2ml:RuleText r2ml:textFormat="plain">
            Increase salary by 10% for these employees who earn less than 2000. And store their names in bonusname attribute.
       </r2ml:RuleText>
   </r2ml:Documentation>
    <r2ml:conditions>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:lessThan">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="salary">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="employee" r2ml:classID="Employee"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="2000" r2ml:datatypeID="xs:positiveInteger"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
    </r2ml:conditions>
 
    <r2ml:producedAction>
 
     <r2ml:CreateActionExpression r2ml:propertyID="Employee">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="employee" />
       </r2ml:contextArgument>         
       <r2ml:DataSlot r2ml:attributeID="name">
         <r2ml:AttributeFunctionTerm r2ml:attributeID="ename">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="eemployee" r2ml:classID="eEmployee"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
       </r2ml:DataSlot>
     </r2ml:CreateActionExpression>
 
     <r2ml:CreateActionExpression r2ml:propertyID="Employee">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="employee" />
       </r2ml:contextArgument>         
       <r2ml:DataSlot r2ml:attributeID="salary">
         <r2ml:AttributeFunctionTerm r2ml:attributeID="esalary">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="eemployee" r2ml:classID="eEmployee"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
       </r2ml:DataSlot>
     </r2ml:CreateActionExpression>
 
    </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>
 
</r2ml:RuleBase>

parallel inference?

De facto InvokeActionExpression służy do wywoływania operacji, a nie do odwoływania się do innych reguł.

<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML"
          xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" 
          xmlns:userv="http://www.businessrulesforum.com/2005/userv#" 
          xmlns:swrlb="http://www.w3.org/2003/11/swrlb"
          xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd">
 
 <r2mlv:Vocabulary> 
   <r2mlv:Class r2mlv:ID="System1"> 
    <r2mlv:Attribute r2mlv:ID="in1">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="con1">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 
   <r2mlv:Class r2mlv:ID="System2"> 
    <r2mlv:Attribute r2mlv:ID="in2">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="con2">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 
  <r2mlv:Class r2mlv:ID="Internal"> 
    <r2mlv:Attribute r2mlv:ID="x">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="y">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
    <r2mlv:Attribute r2mlv:ID="s">
      <r2mlv:range>
       <r2mlv:Datatype r2mlv:ID="xs:string"></r2mlv:Datatype>
      </r2mlv:range>
    </r2mlv:Attribute>
   </r2mlv:Class>
 </r2mlv:Vocabulary>
 
 
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:ruleID="parallel_inference">
   <r2ml:Documentation>
       <r2ml:RuleText r2ml:textFormat="plain">
            parallel inference?
       </r2ml:RuleText>
   </r2ml:Documentation>
    <r2ml:conditions>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:equal">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="x">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="internal" r2ml:classID="Internal"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="true" r2ml:datatypeID="xs:string"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:equal">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="y">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="internal" r2ml:classID="Internal"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="true" r2ml:datatypeID="xs:string"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
        <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:equal">
          <r2ml:dataArguments>
            <r2ml:AttributeFunctionTerm r2ml:attributeID="s">
              <r2ml:contextArgument>
                <r2ml:ObjectVariable r2ml:name="internal" r2ml:classID="Internal"/>
              </r2ml:contextArgument>
            </r2ml:AttributeFunctionTerm>
              <r2ml:TypedLiteral r2ml:lexicalValue="true" r2ml:datatypeID="xs:string"/>
          </r2ml:dataArguments>
        </r2ml:DatatypePredicateAtom>
 
    </r2ml:conditions>
 
    <r2ml:producedAction>
 
      <r2ml:InvokeActionExpression r2ml:propertyID="in1_y">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:classID="System1" r2ml:name="system1" />
       </r2ml:contextArgument>
      </r2ml:InvokeActionExpression>
 
      <r2ml:InvokeActionExpression r2ml:propertyID="in2_y">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:classID="System2" r2ml:name="system2" />
       </r2ml:contextArgument>
      </r2ml:InvokeActionExpression>
 
    </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>
 
</r2ml:RuleBase>
pl/miw/miw08_xtt_r2ml.1212265232.txt.gz · ostatnio zmienione: 2019/06/27 15:58 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0