We’ve loosely defined the idea of a “rules engine” in 601R for a reputation framework. The gist is that an application that wants to use the reputation framework can define a set of rules upon which its own custom reputation scores can be defined and calculated. For example, a blogging reputation system might want to provide a reputation score for its participants. The score might be based on a number of variables: numberOfPosts, LengthOfPosts, NumberOfComments, RelevancyOfPosts, ContentCategory, etc. The blogging system has its own “special formula” for computing the reputation score. This formula is some sort of mathematical expression like:
(numberOfPosts + numberOfComments) * RelevancyOfPosts
Of course, this example might not make any sense. The point is that the rules engine needs a way for the blogging system to define such a mathematical expression. I envision an XML based approach that includes nodes representing basic operators like <add>,<subtract>,<multiply>,
<divide>, and others like <sum>,
<product>,<average>,<median>, and even more complicated ones like <standardDeviation>, etc. Nested within these nodes would be variables representing attributes that the blogging system defines such as <numberOfPosts>, <spellingMistakes>, etc. These can be of various types: INTEGER, BOOLEAN, ENUM (good, better, best), etc. The structure of the XML expression could then be evaluated in the same way a functional expression is evaluated in languages like Scheme or Lisp.
Here is an example:
<expression> <multiply> <add> <attribute id="numberOfPosts"/> <attribute id="numberOfComments"/> </add> <attribute id="relevancyOfPosts"/> </multiply> </expression>
The attributes “numberOfPosts” and “numberOfComments” would be INTEGERS while “relevancyOfPosts” might be FLOATING-POINT or DECIMAL. Of course, the types aren’t defined in the expression above but are defined in a separate XML document which is loaded when the expression is evaluated.