-
Notifications
You must be signed in to change notification settings - Fork 10
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
How to query for True/ False in Scallopy #4
Comments
Yes! Currently, this is the dumbest but most direct way
I'm working on a patch in which the following syntax will be supported:
Hope this answers your question! |
I colud not find any example code making a query using "Scallopy" Python code. All query codes use Scallop syntax.
How do I query the context to get the "blue" ? |
You will be able to query an output relation. For instance, what you can do is: ctx.add_rule("color_of_obj_0(c) = color(0, c)") # adding a query
ctx.run(). # execute the query
result_facts = list(ctx.relation("color_of_obj_0")) # get the results stored inside of `color_of_obj_0` relation; will likely be [("blue",)]
result = result_facts[0][0] # "blue" |
Thank you for the quick reply, and I'm sorry I did not clarify it. The query should find all the tuples having "blue". The expected result should be: |
In that case, you can write the following ctx.add_rule("blue_objs(o, c) = color(o, c) and c == \"blue\"")
ctx.run()
result_facts = list(ctx.relation("blue_objs")) # [(0, "blue"), (2, "blue")] |
Hello,
I was wondering if it's possible to make a query with a KB in scallopy in which you simply get a True/False or Yes/No answer. For example, within the tutorial, what if I want to check whether a path exists between two nodes without having to list out all of the paths?
Such as
path(0,4)
Thank you in advance.
The text was updated successfully, but these errors were encountered: