-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
’EXISTS' cannot return accuracy results, influenced by the pattern order insider. #14
Comments
Hi, I am trying to reproduce the issue but in my tests the rule: @Rule(
Goal('save-the-day'),
EXISTS(
Hero(name="Death Defying Man"),
Hero(status='unoccupied'),
)
)
def save_the_day(self):
print("The day is saved") and @Rule(
Goal('save-the-day'),
EXISTS(
Hero(status='unoccupied'),
Hero(name="Death Defying Man"),
)
)
def save_the_day(self):
print("The day is saved") both yields the same result. Which |
'1.9.4' please take note I used |
Oh, I think I understand. The example is not very clear, but the behavior is correct. Let me explain: In the definition of This is why the rule in the original example matched and yours don't. The explicit version would be: @DefFacts()
def goal_and_heroes(self):
yield Goal('save-the-day')
yield Hero(name="Death Defying Man", status="unoccupied")
yield Hero(name="Stupendous Man", status="unoccupied")
yield Hero(name="Incredible Man", status="unoccupied") In your case the rule is not matching because there are no heroes with |
I modified the example to remove the implicit value. Please let me know if this way is more clear. |
Thanks for your quickly response, however, you may misunderstood my point. |
You are very welcome, thank you for using experta. For EXISTS to match, there must be at least one instance of each fact inside the EXISTS clause. As you can see the rule is not satisfied because none of the declared facts has |
yeah, indeed the facts |
The behavior that you are describing is not the behavior of the EXISTS clause but the OR clause. Please try the OR clause to see if it meets your requirements. Also, check #8 for another clause that can be helpful to you. |
Thanks for your patient explanations. Yeah, I have not yet fully understood the function of "EXISTS", and fall into confusion about the descriptions in your reference file.
Could you give me more explanations and introductions on application scenarios? |
Result:
However, if I reverse the patterns order in
EXISTS
, the result would be empty.The text was updated successfully, but these errors were encountered: