Add support for filtering invalid groundings out #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As you already know, doing outer join on constants produces many groundings which might be semantically invalid or impossible. This increases the size of the grounding table unnecessarily which in turn impacts performance drastically. To reduce search space, a proper solution might be to allow non-primitive types to be used in place of constants and then, to do type checking. Maybe you have plans for fixing this in a better way. However, here is a small change that makes this possible at least for some applications, in the meantime.
This PR allows developers to define their own neurons or formula (possibly inherited from LNN classes) and add a
filter_valid_groundings
method which takes the data frame of all potential groundings and returns another data frame in place. Thus they have the opportunity to filter out incompatible groundings.