zoukankan      html  css  js  c++  java
  • RuleML 例子

    这个例子正是我们入门中所举得例子:折扣

    原始定义:http://files.cnblogs.com/elvisqi/discount-1.0.ruleml.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <RuleML
    xmlns="http://www.ruleml.org/1.0/xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.ruleml.org/1.0/xsd http://www.ruleml.org/1.0/xsd/datalog.xsd">
      <oid>
        <Ind>
        BUSINESS RULES IN RuleML                            Harold Boley, 1 Apr. 2002
        (revised Nov 2005)
    
        Discounting rules were discussed as an example of prioritized conflict handling
        in Benjamin N. Grosof, Yannis Labrou, Hoi Y. Chan: A Declarative Approach to
        Business Rules in Contracts: Courteous Logic Programs in XML. Proc. EC99.
    
      规则库定义了以下业务规则,他们彼此没有优先顺序,分别是:
      * 顾客和产品折扣的业务规则(推理1、2)
      * 优质顾客、使用链(推理3)
      同时还提供了 某个特定客户(事实3) 的 有关产品的业务事实(事实1、2)

      最后要求这个规则库提供一个用于测试的查询(查询1)

      这些例子可以容易的进一步延伸到:客户分类,产品折扣条件 等
    </Ind>
      </oid>
    
    <Assert mapClosure="universal">
    <oid><Ind>断言的内容,如规则或者事实</Ind></oid>
    
    <Implies>
      <oid>
        <Ind>
        推断 1
        如果顾客是优质的,并且产品是标准的,那么顾客购买这个产品时可以享受5.0 %的折扣  
    
        请注意,一个独立常量可以构成一个完整短语,就像“5.0 %”。它只能用于变量和独立常量,并以具有完全相同的拼写(包括空格)。
    我们可以完善这个标记,通过引入一个“百分之[5.0]”的构造术语,由此从Datalog转向Horn logic
    </Ind> </oid> <if> <And> <Atom> <op><Rel>优质的</Rel></op> <Var>顾客</Var> </Atom> <Atom> <op><Rel>标准的</Rel></op> <Var>产品</Var> </Atom> </And> </if> <then> <Atom> <op><Rel>享受折扣</Rel></op> <Var>顾客</Var> <Var>产品</Var> <Ind>5.0 %</Ind> </Atom> </then> </Implies> <Implies> <oid> <Ind> 推断 2 如果顾客是优质的并且产品是奢侈的,那么顾客购买这个产品时可以享受7.5 %的折扣。 </Ind> </oid> <if> <And> <Atom> <op><Rel>优质的</Rel></op> <Var>顾客</Var> </Atom> <Atom> <op><Rel>奢侈的</Rel></op> <Var>产品</Var> </Atom> </And> </if> <then> <Atom> <op><Rel>享受折扣</Rel></op> <Var>顾客</Var> <Var>产品</Var> <Ind>7.5 %</Ind> </Atom> </then> </Implies> <Implies> <oid> <Ind> 推断 3 如果他在去年最少花费了5000欧元,那么这个顾客是优质的。 请注意,“去年”可以被看作独立常量构成的完整短语。
    它也可以被看作是一个半正式的结构,业务描述过程中使用,而在解释时会被进一步解释的变量。 同样,“最少5000欧元”也可以被看作一个独立常量短语。
    它也可以被看作是一个半正式的结构,最终被替换成“大于”带单位的的数字。
    </Ind> </oid> <if> <Atom> <op><Rel>花费</Rel></op> <Var>顾客</Var> <Ind>最少5000欧元</Ind> <Ind>去年</Ind> </Atom> </if> <then> <Atom> <op><Rel>优质的</Rel></op> <Var>顾客</Var> </Atom> </then> </Implies> <Atom> <oid> <Ind> 事实 1 保时捷是奢侈的。 </Ind> </oid> <op><Rel>奢侈的</Rel></op> <Ind>保时捷</Ind> </Atom> <Atom> <oid> <Ind> 事实 2 本田是标准品。 </Ind> </oid> <op><Rel>标准的</Rel></op> <Ind>本田</Ind> </Atom> <Atom> <oid> <Ind> 事实 3 Peter Miller在去年最少花费了5000欧元. 请注意,在这个例子中“最少5000欧元” 和 “去年” 直接使用的独立常量短语。
    因此,这些半正式结构体可在早期正规化过程阶段,调试规则时使用。
    </Ind> </oid> <op><Rel>花费</Rel></op> <Ind>Peter Miller</Ind> <Ind>最少5000欧元</Ind> <Ind>去年</Ind> </Atom> </Assert> <Query> <oid><Ind>查询内容</Ind></oid> <Atom> <oid> <Ind> 查询 1 为顾客购买任意产品提供享受折扣金额的查询 </Ind> </oid> <op><Rel>折扣</Rel></op> <Var>顾客</Var> <Var>产品</Var> <Var>金额</Var> </Atom> </Query> </RuleML>
  • 相关阅读:
    监控微信小程序中的慢HTTP请求
    详解Vue中的虚拟DOM
    SQL Server 2005 和自增长主键identity说再见——NEWSEQUENTIALID()(转载)
    调用SqlCommand或SqlDataAdapter的Dispose方法,是否会关闭绑定的SqlConnection?(转载)
    如何取消 SqlDataAdapter.Fill() 的执行(转载)
    SQL Server备份时间段内插入的数据依旧进入了备份文件?(转载)
    何谓SQLSERVER参数嗅探(转载)
    关于T-SQL重编译那点事,WITH RECOMPILE和OPTION(RECOMPILE)区别仅仅是存储过程级重编译和SQL语句级重编译吗 (链接)
    SQL Server中,如何查看每个数据库的Owner是哪个SQL Server账户,也就是谁创建的
    SQL Server中INSERT EXEC语句不能嵌套使用(转载)
  • 原文地址:https://www.cnblogs.com/elvisqi/p/3537441.html
Copyright © 2011-2022 走看看