-
Notifications
You must be signed in to change notification settings - Fork 299
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
New primitive SemanticFn: Filter #125
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me.
The only thing I'd perhaps think about a bit more is what formulas do we actually need in the long term. It's very easy to just start adding different types of formulas, but this could get out of control.
Actually, what do you think about making Filter be a different mode inside SuperlativeFormula? The type is the same. In the future, if we support map
, then we could add it there too.
Do we need to add something to SparqlExecutor (at least to say that it's not supported)?
Adding a unittest would be nice, and something to the README.
import java.util.List; | ||
|
||
/** | ||
* (filter x y): Find the set of all elements in x that function y evaluates to a non-empty set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give an example...in particular, so that people know the directionality of y (which should be consistent with SuperlativeFormula).
"Find all cities with more teachers than farmers"
This is a highly requested semantic function. One way to answer the question above in the original set of semantic function is
where the special relation
:
returns an empty set when the argument is empty, and*
otherwise. The relation:
has not been implemented.The proposed semantic function looks like this:
While it is equally long, I think it is a little clearer about what it does.
(filter S F)
is equivalent to{x in S : F(x) not empty}
. Filter is also easier to execute than the generic mark since filter is similar to superlatives (i.e., try plugging each value inS
into the functionF
and see what works).Please refer to
tables/grammars/combined.grammar
of how it could be used in the grammar.