Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding nodes inside a list of list does not seems to work. #449

Open
miahmohd opened this issue Apr 8, 2021 · 0 comments
Open

Embedding nodes inside a list of list does not seems to work. #449

miahmohd opened this issue Apr 8, 2021 · 0 comments

Comments

@miahmohd
Copy link

miahmohd commented Apr 8, 2021

I have a json-ld that contains a 2d list, and I'm struggling to frame it correctly.

The flattened (input) json:

[
    {
        "@id":"http://example.com/resource/Conversation1",
        "@type":[
            "http://example.com/ontology/Conversation"
        ],
        "http://example.com/ontology/triggers":[
            {
                "@list":[
                    {
                        "@id":"http://example.com/resource/Trigger1"
                    }
                ]
            }
        ]
    },
    {
        "@id":"http://example.com/resource/Trigger1",
        "@type":[
            "http://example.com/ontology/Trigger"
        ],
        "http://example.com/ontology/formula":[
            {
                "@list":[
                    {
                        "@list":[
                            {
                                "@id":"http://example.com/resource/pred1"
                            },
                            {
                                "@id":"http://example.com/resource/pred2"
                            }
                        ]
                    },
                    {
                        "@list":[
                            {
                                "@id":"http://example.com/resource/pred3"
                            }
                        ]
                    }
                ]
            }
        ],
        "http://example.com/ontology/next":[
            {
                "@value":"Next"
            }
        ]
    },
    {
        "@id":"http://example.com/resource/pred1",
        "@type":[
            "http://example.com/ontology/PredType"
        ],
        "http://example.com/ontology/negate":[
            {
                "@value":false
            }
        ]
    },
    {
        "@id":"http://example.com/resource/pred2",
        "@type":[
            "http://example.com/ontology/PredType"
        ],
        "http://example.com/ontology/negate":[
            {
                "@value":true
            }
        ]
    },
    {
        "@id":"http://example.com/resource/pred3",
        "@type":[
            "http://example.com/ontology/PredType"
        ],
        "http://example.com/ontology/negate":[
            {
                "@value":false
            }
        ]
    }
]

The frame I used:

{
    "@context":{
        "@version":1.1,
        "@base":"http://example.com/resource/",
        "@vocab":"http://example.com/ontology/",
        "formula":{
            "@container":"@list"
        },
        "triggers":{
            "@container":"@list"
        }
    },
    "@type":"Conversation",
    "triggers":{
        "@type":"Trigger",
        "formula":{
            "@embed":"@always",
            "@type":"PredType"
        }
    }
}

The output generated:

{
    "@context":{
        "@version":1.1,
        "@base":"http://example.com/resource/",
        "@vocab":"http://example.com/ontology/",
        "formula":{
            "@container":"@list"
        },
        "triggers":{
            "@container":"@list"
        }
    },
    "@id":"Conversation1",
    "@type":"Conversation",
    "triggers":[
        {
            "@id":"Trigger1",
            "@type":"Trigger",
            "formula":[
                [
                    {
                        "@id":"pred1"
                    },
                    {
                        "@id":"pred2"
                    }
                ],
                [
                    {
                        "@id":"pred3"
                    }
                ]
            ],
            "next":"Next"
        }
    ]
}

The output I want is:

{
    "@context":{
        "@version":1.1,
        "@base":"http://example.com/resource/",
        "@vocab":"http://example.com/ontology/",
        "formula":{
            "@container":"@list"
        },
        "triggers":{
            "@container":"@list"
        }
    },
    "@id":"Conversation1",
    "@type":"Conversation",
    "triggers":[
        {
            "@id":"Trigger1",
            "@type":"Trigger",
            "next":"Next",
            "formula":[
                [
                    {
                        "@id":"pred1",
                        "@type":"PredType",
                        "negate":false
                    },
                    {
                        "@id":"pred2",
                        "@type":"PredType",
                        "negate":true
                    }
                ],
                [
                    {
                        "@id":"pred3",
                        "@type":"PredType",
                        "negate":false
                    }
                ]
            ]
        }
    ]
}

I can't find a way to embed the nodes inside formula properly, how can I make it work?

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

No branches or pull requests

1 participant