frostyfan109 / tranql

A Translator Query Language
https://researchsoftwareinstitute.github.io/data-translator/apps/tranql
MIT License
0 stars 1 forks source link

Autocompletion of predicates while accounting for the following concept #117

Open frostyfan109 opened 5 years ago

frostyfan109 commented 5 years ago

Currently, autocompletion of predicates is held back in that it can only send the query up the cursor's position because it can deduce that the last token must be where the cursor is located, and therefore where the autocompletion is occurring. This method limits the capabilities of autocompletion, particularly for completion of predicates. When autocompleting a query such as select chemical_substance-[]->disease, where the cursor is between the brackets of a new predicates, the autocompleter is oblivious to the fact that the next concept is disease, and will therefore show all predicates with a source of chemical_substance.

If a method were to be found that was capable of supporting something like this, it would be great. The only thing I can think of is sending two queries:

  1. The query up to the cursor.
  2. The entire query.

One would theoretically be able to tell which token the cursor is at in the entire query by using the position of the last token in the first query. It seems feasible, but it seems like there may be some flaws to this method.

One flaw I've found with this method is that the incomplete parsing of grammar can result in everything after the incomplete part getting parsed incorrectly. When

select chemical_substance->[complete_this]->
 from '/graph/rtx'

is sent, the from is actually parsed as a concept, because keywords are not reserved, which means that when trying to complete the predicate, it is looking for any edges between the type chemical_substance and the type from. It's possible to just make it so that a concept can't be a keyword, but that isn't ideal.

frostyfan109 commented 5 years ago

This also applies to backwards arrows, predicate or not. The query

SELECT chemical_substance-><-gene

when autocompleted between the two arrows will only return any concept that is targeted by chemical_substance, when it should only return concepts that are both targeted by chemical_substance and targeted by gene.