Skip to content

[#212] Integration of new CHAIN operator in tokens-bases query#1055

Open
andre-senna wants to merge 6 commits intomasterfrom
senna-212-2
Open

[#212] Integration of new CHAIN operator in tokens-bases query#1055
andre-senna wants to merge 6 commits intomasterfrom
senna-212-2

Conversation

@andre-senna
Copy link
Contributor

WIP towards #212 Still missing integration with MeTTa queries

After this PR, it's possible to include CHAIN operators in token based queries like these:

        "CHAIN", "0", "1", "2",
            "NODE", "Symbol", "\"chimp\"",
            "NODE", "Symbol", "\"ent\"",
            "LINK_TEMPLATE", "Expression", "3",
                "NODE", "Symbol", "Similarity",
                "VARIABLE", "v1",
                "VARIABLE", "v2",
        "CHAIN", "0", "1", "2",
            "NODE", "Symbol", "\"ent\"",
            "NODE", "Symbol", "\"animal\"",
            "OR", "2",
                "LINK_TEMPLATE", "Expression", "3",
                    "NODE", "Symbol", "Similarity",
                    "VARIABLE", "v1",
                    "VARIABLE", "v2",
                "LINK_TEMPLATE", "Expression", "3",
                    "NODE", "Symbol", "Inheritance",
                    "VARIABLE", "v1",
                    "VARIABLE", "v2",

The syntax of the tokens is like this:

        "CHAIN", <handle>, <tail>, <head>,
            <source>,
            <target>,
            <query>

Where , and specify which link from 's query answers should be considered to build the paths and which target indexes should be considered as tail and head of the link in the path.

can be an uint, meaning one of the handles in query_answer.handles or a string meaning the name of a variable in query_answer.mapping. and are uints indexing the given link targets.

So, for instance, "CHAIN", "0", "1", "2", is saying that for each query answer of the operator will consider the 0'th handle in query_answer.handle (i.e. the first handle) as the link which will build the paths and the targets 1 and 2 will be used as tail and head respectively.

In the first example, the operator will take links like (Similarity h1 h2), (Similarity h2 h3), (Similarity h3 h4) to build paths like: h1 -> h2 -> h3 -> h4 (i.e. (h1, h2), (h2, h3), (h3, h4)).

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 this pull request may close these issues.

1 participant