own-pt / wql

WQL query language
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

HCONS wql transformation #18

Closed yfaria closed 2 years ago

yfaria commented 3 years ago

The WQL conversion to SPARQL when we have a handle constraint is not working properly. For example, the WQL query

h1:[rstr h2]
h3:[]
{h2 =q h3}

translates to

PREFIX mrs: <http://www.delph-in.net/schema/mrs#> 
PREFIX delph: <http://www.delph-in.net/schema/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
SELECT ?x11 ?x8 ?x9 ?x0 WHERE { 
  ?x1 mrs:lowHcons ?x10 . 
  ?x1 mrs:highHcons ?x9 . 
  ?x1 rdf:type mrs:Qeq . 
  ?x0 rdf:type mrs:MRS . 
  ?x7 mrs:rstr ?x9 . 
  ?x7 rdfs:label ?x8 . 
  ?x0 mrs:hasEP ?x7 . 
  ?x10 rdfs:label ?x11 . 
  ?x0 mrs:hasEP ?x10 . } 

in SPARQL. The problem is that ?x7 is an EP, not a handle; and the handle constraint links a hole to a handle. There should be something like ?x7 mrs:hasLabel ?x12 and then the first line of the where clause changes to ?x1 mrs:lowHcons ?x12 .. An alternative is forcing the user to separate what is an predication and what is the handle. In this case, the WQL query would be

h1:[rstr h2]
h3:[lbl h4]
{h2 =q h4}

and the query SPARQL generation would be more direct and closer to the WQL one.

arademaker commented 3 years ago

why renaming the variables in the first place? this is very confusing what not using the same variables from the WQL?

SELECT * WHERE { 
  ?qeq1 mrs:lowHcons ?h2 . 
  ?qeq1 mrs:highHcons ?h3 . 
  ?x0 rdf:type mrs:MRS . 
  ?x0 mrs:hasEP ?ep1 . 
  ?x0 mrs:hasEP ?ep2 . 
  ?ep1 mrs:rstr ?h2 . 
  ?ep1 rdfs:label ?h1 . 
  ?ep2 rdfs:label ?h3 . 
} 

Another problem is the use of rdfs:label for the predication label... this is an error. The rdfs:label has an specific meaning and the range is a literal. I don't think it would make sense to have the lbl and the h : ... in the language. Note that:

[ _cat_n_1<4:7> LBL: h7 ARG0: x3 ]

has the fingerprint:

h7:  _cat_n_1[ARG0 x3]
yfaria commented 3 years ago

The variables are renamed because we are using hsparql to translate from WQL to SPARQL and it doesn't let us name the variables directly. We could fiddle with it to figure a way to change it for our needings, but I don't think that it's that important. About the rdfs:label, it's not about the label of an EP; the relation that is used for that is mrs:hasLabel with domain on mrs:ElementaryPredication and range on mrs:h as declared here. The rdfs:label is being used to get the predicate to highlight it on WSI.

yfaria commented 2 years ago

Closing the issue because the HCONS problem was solved in 4a11506968059d205a2230c488a1ecb032c8495a. The problem was caused by the fact that the dictionary of variables that the program holds was associating the variable of a predication to the predication, not the the handle that labels the predication.

There is the problem of the naming of variables in the resulting SPARQL query and the problem with rdfs:label, which should be put in other issue.