-
Notifications
You must be signed in to change notification settings - Fork 16
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
preserve data type #5
Conversation
Cool! :) Let me know! |
sorry for this cryptic issue! we notticed it together with Markus Lanthaler during our short meeting in Graz yesterday and I didn't want to use too much time for writing proper bug report... var levelgraph = require('levelgraph');
var lgJSONLD = require('levelgraph-jsonld');
var db = lgJSONLD(levelgraph('test'));
var graz = {
"@context": {
"@vocab": "http://schema.org/"
},
"@id": "http://dbpedia.org/resource/Graz",
"@type": "City",
"name": "Graz",
"geo": {
"latitude": 47.0708101,
"longitude": 15.4382918
}
};
db.jsonld.put(graz, function() {
db.jsonld.get(graz["@id"], { "@context": graz["@context"] }, function(err, doc) {
console.log(doc);
});
}); running it prints { '@context': { '@vocab': 'http://schema.org/' },
'@id': 'http://dbpedia.org/resource/Graz',
'@type': 'City',
geo:
{ '@id': '_:f26890d0-5e5f-11e3-b04e-e3cb44466f3c',
latitude: '4.70708101E1',
longitude: '1.54382918E1' },
name: 'Graz' as you see latitude and longitude turned into strings |
this is fun! :) Would you like to propose a fix? |
i'll try to chew on it but in next days hitchhiking might take some of my time :( i understand that we only need to preserve type of object since subject and predicate always stay IRIs. at first sight i didn't notice exact place where numbers get converted into strings! maybe we could use Tripple Properties for that? https://github.com/mcollina/levelgraph#triple-properties something in lines: "objectType": "xsd:double"... BTW this one looks relevant: http://json-ld.org/spec/latest/json-ld-api/#data-round-tripping and another one: http://json-ld.org/spec/latest/json-ld/#dfn-value-type |
we also need to make sure that we can use it together with N3/Turtle extension ... will need to check how it happens over there! |
Exactly, that was my idea, check what N3.js is doing and be consistent, so that the modules are interoperable. :) |
var lg = require('levelgraph');
var lgN3 = require('levelgraph-n3');
var db = lgN3(lg('test'));
var turtle = "@prefix c: <http://example.org/cartoons#>.\n" +
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\n" +
"c:Tom a c:Cat.\n" +
"c:Jerry a c:Mouse;\n" +
" c:smarterThan c:Tom;\n" +
" c:place \"fantasy\";\n" +
" c:iq \"200\"^^xsd:integer.";
db.n3.put(turtle, function() {
db.get({ predicate: 'http://example.org/cartoons#iq' }, function(err, triples) {
console.log(triples);
});
}); prints out [ { subject: 'http://example.org/cartoons#Jerry',
predicate: 'http://example.org/cartoons#iq',
object: '"200"^^<http://www.w3.org/2001/XMLSchema#integer>',
context: 'n3/contexts#default' } ] and it makes sense to just store object type within the object itself 😄 i'll play with https://github.com/mcollina/levelgraph-jsonld/blob/master/index.js#L37-L48 and make sure that for object we add datatype to value in triples returned by jsonld.toRDF() i hope to find some time tomorrow and just fix it... starting with writing proper tests! |
👍 |
@mcollina please don't merge yet! i just wanted to share initial experiment and refactor both tests and implementation ... i need to go through jsonld.js since most of that logic exists already over there and i would prefer to reuse it instead of duplicating. |
oops! i thought i can rebase and attach new pull request to this issue... looks like now i will need to create new PR! |
what's the state on this? |
looks like i can't re-open this one and will need to create another one... need to stay careful in a future not to convert issues into pull-request! end of this week and early next week i plan some time to re-implement it in new way also addressing #4 |
just noticed it and will post way of reproducing in hour or two ;)