ufal / perl-pmltq

Query engine and query language for trees in PML format
3 stars 2 forks source link

Btred/SQL Evaluator - opposite behaviour on order relations order-follows/order-precedes #64

Open matyaskopp opened 1 year ago

matyaskopp commented 1 year ago

Email report (@lauma, subj:Possible bug in LINDAT's PMLTQ instance?, 20230524) :

... For example this query: http://hdl.handle.net/11346/PMLTQ-2CJO. In LINDAT adjective is before noun. If I connect to the same https://lindat.mff.cuni.cz/services/pmltq/#!/treebank/lvtb211/query/ with TrEd (v2.5236) and PMLTQ extension (pmltq 2.14, picture below), result is the same. However, if I query local data (attached both data sample and tred extension for that), the order is opposite ...

Minimal example:

a-node $A:= [ order-follows a-node $B := [] ];
  • SQLEvaluator: A follows B
  • BtredEvaluator: A is followed by B
dan-zeman commented 1 year ago

The relations order-follows and order-precedes always puzzled me. I never know what is supposed to follow what.

jmirovsky commented 1 year ago

The consistent behaviour is the one implemented in btred evaluator, i.e. the relation defines the property of the subsequently mentioned/defined node (similarly to other relations, such as child, parent etc.), i.e. order-follows $b should mean that node $b is the following one.

matyaskopp commented 1 year ago

The consistent behaviour is the one implemented in btred evaluator, i.e. the relation defines the property of the subsequently mentioned/defined node (similarly to other relations, such as child, parent etc.), i.e. order-follows $b should mean that node $b is the following one.

I am not sure if I agree, If I correctly understand this note inside implementation: https://github.com/ufal/perl-pmltq/blob/03718a4b0af59ab906f14154c5153ce3d6d7db5b/lib/PMLTQ/BtredEvaluator.pm#L182-L199 it is the BtredEvaluation which is wrong.

But the implementation says different things: https://github.com/ufal/perl-pmltq/blob/03718a4b0af59ab906f14154c5153ce3d6d7db5b/lib/PMLTQ/BtredEvaluator.pm#L756-L760

In SQLEvaluator, notes are missing, and the implementation is just reversion: https://github.com/ufal/perl-pmltq/blob/03718a4b0af59ab906f14154c5153ce3d6d7db5b/lib/PMLTQ/SQLEvaluator.pm#L858-L860

matyaskopp commented 1 year ago

in SQLEvaluator, depth-first-follows behaves consistently with order-follows: http://hdl.handle.net/11346/PMLTQ-ATS3

a-node $A:=[ depth-first-follows a-node $B :=[ ] ];

image

dan-zeman commented 1 year ago

The consistent behaviour is the one implemented in btred evaluator, i.e. the relation defines the property of the subsequently mentioned/defined node (similarly to other relations, such as child, parent etc.), i.e. order-follows $b should mean that node $b is the following one.

Regardless whether the comments in the source code support it or not, this behavior would be consistent (between parent/child on one side and order-precedes/follows on the other) and thus would make sense.

But even then the name of the relation is unfortunate and confusing. Since it sounds like the English language, the most natural interpretation of "order follows node B" is that something follows B, not that B follows something. So we have a conflict between consistency with parent/child and natural interpretation of the name. Ideally, I would maintain consistency with parent/child relations, but rename the order relations to avoid third-person finite verbs. Maybe something like order-following and order-preceding would be better. It would still not be self-explanatory w.r.t. the relation direction, but at least it would not hint at the wrong direction. And the full string with "node" would actually read naturally to me:

a-node $a := [order-following a-node $b := [...]]
matyaskopp commented 1 year ago

The consistent behaviour is the one implemented in btred evaluator, i.e. the relation defines the property of the subsequently mentioned/defined node (similarly to other relations, such as child, parent etc.), i.e. order-follows $b should mean that node $b is the following one.

Regardless whether the comments in the source code support it or not, this behavior would be consistent (between parent/child on one side and order-precedes/follows on the other) and thus would make sense.

But even then the name of the relation is unfortunate and confusing. Since it sounds like the English language, the most natural interpretation of "order follows node B" is that something follows B, not that B follows something. So we have a conflict between consistency with parent/child and natural interpretation of the name. Ideally, I would maintain consistency with parent/child relations, but rename the order relations to avoid third-person finite verbs. Maybe something like order-following and order-preceding would be better. It would still not be self-explanatory w.r.t. the relation direction, but at least it would not hint at the wrong direction. And the full string with "node" would actually read naturally to me:

a-node $a := [order-following a-node $b := [...]]

Agree, and this naming is also consistent with the XPath query language.

Safer is probably adding new relations and not removing the old ones: