在 Drools 中定位语法错误

发布于 2024-12-24 17:49:48 字数 3967 浏览 2 评论 0原文

我有一个流口水的文件,其中规则 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

尽管对于指定值,条件为 false ,但为什么它总是进入其中的

。请找到所有文件。

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

任何人都可以帮助我为什么它是 entring 是 list3 尽管上面提供的数据并不使它有效

I have a drool file where rule 2 is always coming out to true.

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

the value of

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

Why it is going into it always though for specified value the condition is false .

Kindly find the all files.

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

Can anybody help me why it is enetring is list3 though data as provided above is not making it valid

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姜生凉生 2024-12-31 17:49:48

查看为您的规则生成的 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))

希望这会有所帮助。

It could also be helpful to look at the generated java class for your rule and see what the issue might be.
Use:
-Ddrools.dump.dir=
to set path for the generated code.

It could also be helpful to set a rules listener and look at the fact insertions updates and rules firing sequence.

Also you could try to break the problematic rule into two rules without DSL as follows for debug purpose:

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))

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文