Skip to content
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

Operator negation in AQL - part 2: negation without existence assumption #187

Closed
amir-zeldes opened this issue Aug 19, 2013 · 2 comments · Fixed by #200
Closed

Operator negation in AQL - part 2: negation without existence assumption #187

amir-zeldes opened this issue Aug 19, 2013 · 2 comments · Fixed by #200

Comments

@amir-zeldes
Copy link

amir-zeldes commented Aug 19, 2013

This enhancement extends #186 , negation with existence assumption, and should probably be implemented after that issue is closed.

Often, we want a negative search to confirm that some element does not interact with our data in some way. This element doesn't have to exist: we just want to make sure it is not there (i.e. nothing, the empty set is fine as fulfilling the place of #n). This probably requires a "where not exists..." clause in the SQL generation.

It will be necessary to mark potentially non-existent elements in AQL. This will be done by suffixing a ? to the search expression. Here are some examples: suppose we want to find all NPs not dominated by a PP. It is not the case that a PP needs to be found and then checked for dominance of the NP. We simply want to go over everyone who dominates the NP (if at all) and make sure that none of them are PPs. We therefore explicitly state that we are not really searching for the PP. Note that the PP cannot be bound to the positive nodes in the query (those without ?) - otherwise its existence is implied and the solution in #186 applies. Here is the query:

cat="NP" & cat="PP"? & #2 !> #1

This finds all NPs, then checks whether a cat="PP" exists which dominates them. If so, they are removed from the result set.

In the context of this issue, only simple annotation searches are valid as operands of the negated operator. It is not possible to connect two optional elements with a negated or non-negated operators. More complex structures would be introduced by #199 .

@thomaskrause
Copy link
Member

thomaskrause commented Sep 14, 2021

@amir-zeldes I'm almost finished implementing this in PR #200, but I changed the syntax from a prefix ? to a postfix ? (optional nodes were marked with ?tok and is now marked with tok?. Is there a specific reason why we decided on prefix-? previously?.

The motivation to change this is:

  • to allow an AQL parser to differentiate the context in case we will use the ? operator e.g. for optional terms (regex-style)
  • to be more comparable to the regular expression operator. It is always confusing when special characters from regex behave differently in AQL (like .) and having the ? at the front would be more confusing in my opinion.

@amir-zeldes
Copy link
Author

Wow, this is amazing!!

The notation seems OK to me - the only disadvantage is the graphical dissimilarity of the case with key=val vs. just key, since "?" is sometimes adjacent to the key name and sometimes not:

key?
key="val"?

But I agree with your reasoning. Also note that #199 still has an example of the prefix notation.

Fantastic work implementing this, I really want to switch to ANNIS4 now!

bors bot added a commit that referenced this issue Sep 16, 2021
200: Implement negation for non-existing nodes r=thomaskrause a=thomaskrause

This implements #187 but does not implement the more complex structures (as described in #199) yet. Also note that we changed form a prefix ? to a suffix, to make it easier to implement optional parts of the query term in the AQL parser later on when needed.

We implement these negated operators with non-existent operands as unary operators (with the existing node as the one that is filtered using the non-existent expression). There is also some refactoring and renaming to make it easier to use the value filter functions outside the conjunction code (in our operator) to avoid duplicated implementation of the node search logic.

Co-authored-by: Thomas Krause <[email protected]>
Co-authored-by: Thomas Krause <[email protected]>
@bors bors bot closed this as completed in #200 Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants