Comments (15)
jsonld.compact
reverses the expand action as far as I know.
from reproschema-ui.
Actually, we should just define the mapping separately.
@sanuann can you add another field in schema-standardization that preserves the mapping between items that are used to evaluate scoringLogic
and branchingLogic
?
from reproschema-ui.
I just realized you can string multiple prefixes together, so jsonld.compact might not help
EDIT: compact-ing doesn't help
from reproschema-ui.
compact doesn't seem to hel
from reproschema-ui.
Didn't get you. Why doesn't compacting help?
from reproschema-ui.
this is an issue, but since scoring and branching are javascript code. that's not a clean implementation, and something has to translate the javascript variables to "values/keys" outside that scope. i expect that to help with the mapping. this can be done prior to expansion, but i would not put in the schema.
the other way is to get the mapping from the id of the jsonld file:
https://github.com/ReproNim/schema-standardization/blob/master/activities/PHQ-9/items/phq9_1.jsonld#L6
the most important thing that we need to get out of this is that response keys are URIs to items and response values are a literal or a controlled dictionary.
from reproschema-ui.
I noticed that the @id get expanded as well. But @sanuann just told me that Redcap uses "altLabel" to refer to variables in equations, so I'll add an issue to implement it that way instead
from reproschema-ui.
Losing context shouldn't be an insurmountable issue; well-formed IRIs should resolve to include or link to all of the necessary context, right?
from reproschema-ui.
Let me restate the problem, this might help with my confusion:
-
The main goal of this project is to be able to reuse items. So items have a unique ID, e.g. a URI.
-
In JSONLD, we define a prefix so we can refer to these URIs without typing them out. When the jsonld is expanded, these prefix are replaced with the URI.
-
We need to define branching and scoring logic, in terms of the items. In the current implementation, we refer to the items, again, with their prefix.
-
But when we expand the JSONLD, these prefixes aren't replaced with URIs, which means we need to figure out this mapping, somehow!
Our hack for getting this to work quickly was that I noticed we named our files with the same name as the prefix. But, as we move to a schema-server for all this, we can't make this filename assumption.
Here are the workarounds I can think of:
- encode once again the prefixes to URIs separately in the activity
- use the altLabel of the item. as the mapping instead.. but I don't like this because we can't assume this will be unique, so I'm nixing this.
- use the
@id
of the item, but a) this gets expanded, and b) this should be a unique id (because if we are reusing items, there shouldn't be a clash on ids). Since it will be unique, it might not have a human-meaningful name to refer to in formulas, so i'm nixing this too. - figure out how to extract those prefixes again. Are our jsonld's not formatted correctly? A hack for this would be to load the jsonld as a JSON, and then expand its contents using the library.
Any other ideas?
from reproschema-ui.
I don't follow 2‒4 in the problem restatement.
When the jsonld is expanded, these prefix are replaced with the URI.
…
But when we expand the JSONLD, these prefixes aren't replaced with URIs
The whole point of JSON-LD prefixing is that expanding the prefix + the suffix results in a dereferencable IRI. In Mindlogger, the entity ID can be encoded; on GitHub, the raw URL. If the prefix:suffix doesn't expand into a dereferencable string, the syntax is incorrect. We don't need to know or care about filenames so long as we have an API that can route us based on these strings.
compact IRI
A compact IRI is has the form of prefix:suffix and is used as a way of expressing an IRI without needing to define separate term definitions for each IRI contained within a common vocabulary identified by prefix.
from reproschema-ui.
On the jsonld playground: https://json-ld.org/playground/
if you copy/paste the PHQ-9 activity: https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/PHQ-9/phq9_schema.jsonld
and look at the expanded result, there is no way for me to know that phq9_1
corresponds to https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/PHQ-9/items/phq9_1.jsonld
This is a problem because I refer to it in the "visibility" section, to calculate whether or not to show an item. I'm not familiar with jsonld enough to know how to keep the mapping in the expanded result.
The whole point of JSON-LD prefixing is that expanding the prefix + the suffix results in a dereferencable IRI. In Mindlogger, the entity ID can be encoded; on GitHub, the raw URL. If the prefix:suffix doesn't expand into a dereferencable string, the syntax is incorrect. We don't need to know or care about filenames so long as we have an API that can route us based on these strings.
The problem is that prefix:suffix DOES expand into a dereferencable string, but it isn't happening in the branching logic or scoring equation sections. And we lose the reference in other places (which is correct behavior)
from reproschema-ui.
@akeshavan - you cannot. the expanded form is a graph, which is why there is a mismatch between using keys (for json simplicity) in scoring/branching, when the underlying data model has no concept of it. we are also taking account of a default vocabulary that let's us use those string keys without a prefix.
there may be a middle ground, but i do want to think about this more carefully. let's not hack a hack at this point and solve it with a proper solution.
from reproschema-ui.
@satra any ideas? :)
from reproschema-ui.
@satra aren't we using the variableMap
now to resolve this?
from reproschema-ui.
yes. closing.
from reproschema-ui.
Related Issues (20)
- [Time sensitive] It allows Next activity before current activity is finished HOT 10
- [Urgent] subitem hangs HOT 2
- [urgent] Save global parameter value to zip filename HOT 9
- Left-aligning text HOT 1
- Make MultiTextInput more general
- Update README and demo protocol with textArea widget
- [priority] Warning message when user tries to refresh page
- [priority] improve data submission re-attempts HOT 2
- Test audio speaker and headphone check
- any plans to merge all the dependabot alert PRs? HOT 4
- the content of consent form is hard-coded in the `sign` component HOT 4
- where to define "survey/activity completion and moving on to the next activity" HOT 2
- Update README.md with instructions for deploying at GitHub personal site HOT 2
- update with new enumerations for allowed and missing types
- "Serve the app on your computer" instructions don't work due to deprecated dependencies HOT 1
- Prior completion not enforced correctly HOT 1
- Errors when creating a protocol with one item HOT 7
- Changing response removes next button HOT 2
- Error When Double-Clicking Activity
- Multiple input select items render incorrectly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reproschema-ui.