pyld icon indicating copy to clipboard operation
pyld copied to clipboard

does pyld support content negotiation?

Open sanuann opened this issue 4 years ago • 2 comments

I am trying to run pyld functions (expand, normalize) on the document below but it doesn't seem to get the context urls linked.

    doc = {
                "@context": [
                    "https://schema.repronim.org/rl/contexts/generic",
                    "https://schema.repronim.org/rl/activities/PHQ-9/phq9_context"
                ],
                "@type": "reproschema:Activity",
                "@id": "phq9_schema",
                "skos:prefLabel": "PHQ-9 Assessment",
                "schema:description": "PHQ-9 assessment schema",
                "schema:citation": "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1495268/",
                "preamble": {
                    "en": "Over the last 2 weeks, how often have you been bothered by any of the following problems?",
                    "es": "Durante las últimas 2 semanas, ¿con qué frecuencia le han molestado los siguintes problemas?"
                }
    }
    normalized_file = jsonld.normalize(doc, {'algorithm': 'URDNA2015', 'format': 'application/n-quads'})

This doesn't work on the JSON-LD playground either. how can I make this work? Does pyld support content negotiation/Is there a way to force accept-header?

sanuann avatar Mar 03 '20 21:03 sanuann

Seems like this is a problem with schema.org contexts as well (https://github.com/schemaorg/schemaorg/issues/2578#issuecomment-632227864)

I was stuck in the same problem. Ended up using requests to get the context JSON separately and assign it to @context key at runtime. Then the pyld functions work!

Hope this helps

umang0202 avatar Jun 03 '20 18:06 umang0202

"https://schema.repronim.org/rl/activities/PHQ-9/phq9_context" is returning 405 as of today. Removing that URL and playground or pyld can expand things. If you want the normalize call to work the "@id": "phq9_schema" needs to be a valid URI. If you change that to "@id": "urn:phq9_schema", you'll get output.

davidlehn avatar Jun 05 '20 01:06 davidlehn