在Drools中找到语法错​​误

时间:2012-01-05 10:07:32

标签: drools

我有一个流氓文件,其中规则2总是变为真。

rule "R2"
salience 1000

when

((residence status = "US Citizen") || ((residence status = "Lawfully-entered Alien") and (residence duration >= 5))) and (fpl <= 133)
then

Add to Programs List "3"
end

的值
residence status is US Citizen
residence status is null 
residence duration is 0
fpl is 278.77

为什么它总是进入它,但是对于指定的值,条件是假的。

请找到所有文件。

package com.eligibility.service;  


import com.platform.enrollment.domain.BasicInfo;
import com.platform.enrollment.domain.FamilyMember;
global java.util.List prog_id_list; 
global java.lang.Double fpl;

[condition][] and=and 
[condition][] or=or

[condition][]residence status \= "{value}"=FamilyMember(basicInfo.citizenshipStatus == "{value}")
[condition][]residence duration >\= {value}=FamilyMember(basicInfo.permanentResidenceDuration >= {value})
[condition][]job status \= "{value}"=FamilyMember(basicInfo.jobStatus == "{value}")
[condition][]large business status \= "{value}"=FamilyMember(basicInfo.largeBusinessStatus == "{value}")
[condition][]false=eval(false)
[condition][]true=eval(true)
[condition][]age \= {value}=FamilyMember(basicInfo.getAge=={value})
[condition][]age < {value}=FamilyMember(basicInfo.getAge<{value})
[condition][]age > {value}=FamilyMember(basicInfo.getAge>{value})
[condition][]age <\= {value}=FamilyMember(basicInfo.getAge<={value})
[condition][]age >\= {value}=FamilyMember(basicInfo.getAge>={value})

[condition][]fpl \= {value}=eval(fpl=={value})
[condition][]fpl < {value}=eval(fpl<{value})
[condition][]fpl > {value}=eval(fpl>{value})
[condition][]fpl <\= {value}=eval(fpl<={value})
[condition][]fpl >\= {value}=eval(fpl>={value})

[condition][]gender \= "{value}"=FamilyMember(basicInfo.gender == "{value}")

[condition][]pregnant \= true=Applicant(eval(pregnant))
[condition][]pregnant \= false=Applicant(eval(!pregnant))

[condition][]Family member age greater than or equal to 60 \= true=eval(any_member_greater_than_equal_to_60)
[condition][]Family member age greater than or equal to 60 \= false=eval(!any_member_greater_than_equal_to_60)

[condition][]job status \= "{value}"=Applicant(eval(job_status.contains("{value}")))

[condition][]large business status \= "{value}"=Applicant(eval(large_business_status.contains("{value}")))
[condition][]employer benefits \= "{value}"=Applicant(eval(large_business_status.contains("{value}")))

[condition][]spouse \= true=eval(spouse)
[condition][]spouse \= false=eval(!spouse)

[condition][]total assets \= {value}=eval(total_assets=={value})
[condition][]total assets < {value}=eval(total_assets<{value})
[condition][]total assets > {value}=eval(total_assets>{value})
[condition][]total assets <\= {value}=eval(total_assets<={value})
[condition][]total assets >\= {value}=eval(total_assets>={value})

[condition][] Question with code "{code}" has answer "{answer}"=Question(code=="{code}"&& eval(answer.contains("{answer}")))

[consequence][]Add to Programs List {id}=prog_id_list.add({id});    

rule "R0"
salience 1000

when

(age <= 0) and ((residence status = "US Citizen") || (residence status = "Lawfully-entered Alien")) and (fpl <= 200)
then

Add to Programs List "1"
end

rule "R1"
salience 1000

when

((residence status = "US Citizen") || (residence status = "Lawfully-entered Alien")) and (fpl >= 400)
then

Add to Programs List "2"
end

rule "R2"
salience 1000

when

((residence status = "US Citizen") || ((residence status = "Lawfully-entered Alien") and (residence duration >= 5))) and (fpl <= 133)
then

Add to Programs List "3"
end

rule "R3"
salience 1000

when

((residence status = "US Citizen") || (residence status = "Lawfully-entered Alien")) and (fpl > 133) and (fpl < 400)
then

Add to Programs List "4"
end

虽然上面提供的数据不是有效的,但是有人可以帮助我为什么它是enetring是list3

2 个答案:

答案 0 :(得分:0)

您能分享规则的DRL版本的样子吗?如果我们没有所有的映射,我们就无能为力。通常要制定从DRL开始的规则,当规则正常工作时,您可以创建适当的映射。看起来你正在做相反的事情。 干杯

答案 1 :(得分:0)

查看生成的规则java类并查看问题可能也会有所帮助。 使用: -Ddrools.dump.dir = 为生成的代码设置路径。

设置规则监听器并查看事实插入更新和规则触发序列也可能会有所帮助。

此外,您可以尝试将有问题的规则分解为两条规则而不使用DSL,如下所示:

when
FamilyMember(basicInfo.citizenshipStatus == "US Citizen")
Fact(eval(fpl <= 133))

when
FamilyMember(basicInfo.citizenshipStatus == "Lawfully-entered Alien")
FamilyMember(basicInfo.permanentResidenceDuration >= 5)
Fact(eval(fpl <= 133))

希望这有帮助。