New primitive SemanticFn: Filter#125
New primitive SemanticFn: Filter#125ppasupat wants to merge 8 commits intopercyliang:masterfrom ppasupat:filter
Conversation
percyliang
left a comment
There was a problem hiding this comment.
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.
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 inSinto the functionFand see what works).Please refer to
tables/grammars/combined.grammarof how it could be used in the grammar.