-
Notifications
You must be signed in to change notification settings - Fork 7
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
Semantic filtering and tagging API #137
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.
As all of this (and the client changes) are very generic and do not do anything currently, some documentation how to use this, some tests, or simple examples should be added to show what this does.
...ins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/filtering/GreaterThanConnective.java
Outdated
Show resolved
Hide resolved
...ns/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/filtering/SemanticFilterRuleUtil.java
Outdated
Show resolved
Hide resolved
I've updated the PR description with a small usage guide and some simple examples. This could later be moved to the wiki for developers. |
Signed-off-by: Max Kasperowski <[email protected]>
Signed-off-by: Max Kasperowski <[email protected]>
Signed-off-by: Max Kasperowski <[email protected]>
Signed-off-by: Max Kasperowski <[email protected]>
Signed-off-by: Max Kasperowski <[email protected]>
Signed-off-by: Max Kasperowski <[email protected]>
Update java version requirements
Wrote a util for parsing semantic filter rules
superseded by #129 |
kieler/klighd-vscode#109
Wiki Page Draft
Semantic Filtering Tags
SemanticFilterTag
s can be added to a graph element with the propertyde.cau.cs.kieler.klighd.semanticFilter.tags
. They contain a string that serves to convey semantic information. A tag also acts as an atomicSemanticFilterRule
that evaluates to true for an element if that element contains a tag with the same string.Semantic Filtering Rules
A graph element can contain a list of
SemanticFilterRule
s. Depending on the intended use case it may make sense to attach different rules to different graph elements, but in the use cases we consider here, rules would apply to the entire graph. Therefore, rules are only attached to the root node. It is up to the client feature (e.g. proxy-view) to look for and apply rules on a graph.Constructing Rules
A
SemanticFilterTag
,TrueConnective
andFalseConnective
are atomic rules. Rules can be constructed using connectives and other rules. The following logical connectives are defined:Numeric Tags and Rules
A
SemanticFilterTag
can also have a number in addition to a string and there are special numerical connectives that take aSemanticFilterTag
as an operand and evaluate to true or false according to the number saved in that tag. The following numeric connectives are defined:Numeric Connectives with Numeric Results
The following rules take numeric inputs and output a numeric value themselves. They can be used to construct more complex expressions such as "states" where the sum of "declarations" and "childCount" is larger than some value.
Code Examples
Adding tags and rules on the server
In the following we declare some simple tags and a numeric tag.
We can then assign these tags during the synthesis.
Next, we need some rules that we can use to filter elements on the client.in
Finally we can add the rules to the graph (here we add them to the root node) [xtend].
Expression language for creating filter rules
In addition to the programmatic method of defining rules an expression language may be used.
SemanticFilterRuleParserUtil.parse(<ExpressionString>)
may be used to parse these expressions and obtain the correspondingSemanticFilterRule
.Expressions are built up analogously to the programmatic construction. Each expression is evaluated either to a boolean or numeric value. An atomic expression is either a constant (
true
,false
or a string that can be parsed as Java double) or a tag variable. A tag variable consists of a string identifier (without whitespaces) and is preceded by#
to denote a boolean value i.e. the tag is present or not or by a$
to denote a numeric value. Whitespaces are used as separators between operators and expressions. The table below gives an overview over the available operators. Brackets ((
,)
) may additionally be used to override precedence.Valid example expressions
#initial || $regions >= 3
- keeps all elements that have the taginitial
or have the tagregions
with a value of 3 or higher.$children + $importance > $weight
- keeps all elements where the sum of thechildren
andimportance
tags is higher than the value of theweight
tagEvaluating rules on the client
How exactly a feature on the client uses these tags and rules is flexible. In general the rules should be retrieved from the graph and some decision must be made on how to choose a rule based on its name. Then rules can be applied on graph elements, which allows filtering of elements.
Getting filters from the root
Filter interface
Now using a list of graph elements we can use the
filter
function to apply thisFilter
to all graph elements and get a filtered list of graph elements.