text-fabric
text-fabric copied to clipboard
Outer Names in Inner Quantifiers
I want to revisit the issue of multiple names in quantifiers. There are certain relationships which the present implementation is not able to express.
Here is an example template that is currently not possible. There are two words in a phrase. And we want to specify that a preposition should not intervene between them:
phrase
w1:word
[...]
w2:word
/without/
w1
< word pdp=prep
< w2
/-/
In the current implementation, these kinds of relation expressions can only be approximated by repeating all of the specifications under w1
under a quantifier:
phrase
w1:word
[...]
w2:word
/without/
phrase
w1:word
[...]
< word pdp=prep
w2
/-/
In cases where [...]
contains lots of specs, this becomes unwieldy. Furthermore, there is no guarantee in the above pattern that the w1
in the phrase template will be identical to the w1
in the quantifier template.
I know that there are major difficulties to implementing multiple names in quantifiers. However, if each name is assigned to a node in an outer level, perhaps it is possible to pass those nodes as sets to the inner levels, so that a w1
defined in level 0 can be directly referred to in level 1. Or perhaps there is yet a better way.
I see what you mean. Yet it is a lot of work to get it right. I will not be able to do that in 2018, I'm afraid. Let's keep it on the list.
When I think of it, it should definitely be possible, but there will be an addtional restriction:
- the stuff between the parent and the quantifier may not contain names from elsewhere in the template
Maybe we can think of contextual parentage: the parent node itself comes with its template context. Then TF does not run 2 separate queries from scratch. Could it pass results from a parental template down to a daughter template? Maybe rather than running a second query in the daughter template, you use the first results to narrow the second search. If there is a container relationship expressed, then you can use the container object as a set argument in query 2. If the daughter template goes above the highest object from the mother, you could use an L.u
to go straight to the target.
In such a set-up you would probably get better performance, and the inheritance of context would ensure your subtemplates are mutually intelligible. But maybe there are some drawbacks to such an approach?
Internally a template is translated into a set of query nodes and query edges, without specific order. That query graph gets executed. At the point of execution there is no indentation and scope anymore.
I think the way forward is to let quantifiers quantify not a single parent but a complete subtemplate. The subtemplate must be marked in case if it is more than one parent atom.
---t1
w1:word
< w2:word
---
% other parts of the template
t1
/without/
w1
< word pdp=prep
< w2
/-/
So: named subtemplates. If the quantifier follows the subtemplate immediately, no naming is needed.
But wait, the subtemplates might become nested: if they contain quantifiers themselves. So we need a slightly different bracketing syntax:
{t1
w1:word
< w2:word
}
% other parts of the template
t1
/without/
w1
< word pdp=prep
< w2
/-/
But in this case we may also say
{
w1:word
< w2:word
}
/without/
w1
< word pdp=prep
< w2
/-/
{
and }
should occur on a line on their own, the position in the line does not matter.
What if instead of curly braces it were simply the same slashes as a quantifier? It is interesting, though, that we seem to be working back toward a format that looks nearly MQL-like!
In other words, what if instead of “quantifiers” or “named templates” we have “blocks”
MQL makes you think about your data as a tree. TF search is more conducive to graph thinking, so I am a bit wary about blocks.
Named templates might be useful as an abbreviation mechanism for reusing bits of template. But that will have complications with names.
About using the /: yes that could be nice. Inner subtemplates should be indented with the quantifier they belong too. Hm: that could be a really nice option.
/all/
w1:word
< w2:word
/without/
w1
< word pdp=prep
< w2
/-/
So we only have to add /all/
at the beginning of the template we want to quantify.
It almost sounds doable!
And it sounds right too for all quantifiers:
/all/
things
/where/
these things
/have/
those things
/-/
/all/
things
/with/
these things
/or/
those things
/-/
/all/
things
/without/
them things
/-/
I like that...But maybe the subtemplate should follow an all termination. As it is above, we cannot issue a template on w2 by itself. What about:
/all/
w1:word
< w2: word
/-/
/without/
w1
< word pdp=prep
< w2
/-/
At the same time, these two templates would return identical results:
w1:word
< w2: word
/all/
w1:word
< w2:word
/-/
So the all
quantifier is optional, if you want to quantify an entire template you can use it. If not, you can ignore it.
Why do we need the extra /-/ ?
This should be possible too:
w1:word
/all/
< w2:word
/without/
< word pdp=prep
< w2
/-/
Reason I was thinking the extra ending marker...the diff between this:
/all/
w1:word
< w2:word
/without/
w1
< word pdp=prep
< w2
/-/
and this:
/all/
w1:word
< w2:word
/without/
ls=card
/-/
/without/
w1
< word pdp=prep
< w2
/-/
is a bit subtle. But it does work
I think you need an extra /all/ for that. But I have to admit that I should sleep on this one first
This is a resumption of #9.
I am not able to follow this up in the foreseeable future.