- From: Antoine Zimmermann <antoine.zimmermann@emse.fr>
- Date: Fri, 30 Mar 2018 10:29:04 +0200
- To: Axel Polleres <axel@polleres.net>, semantic-web@w3.org
Axel, Adding a valid @context to an existing JSON file will make a valid JSON-LD file, and therefore yield an RDF graph, but in all but the simplest cases, it will not be the graph you want. From my experience, any non trivial data integration task with JSON and RDF will require a change in the structure of the JSON tree that cannot be emulated with any @context construction. For such cases, you need a more expressive way to map JSON to RDF, either by programming a dedicated application or using a generic purpose mapping language, such as RML [1] or SPARQL-Generate [2] (or maybe XSPARQL?). Being involved in the development of SPARQL-Generate, I recommend it! :) I wrote a transformation for you: https://www.emse.fr/~zimmermann/Data/geojson/query-geojson.rqg which applies to your example data that I put at: http://www.emse.fr/~zimmermann/Data/geojson/geo.json The transformation is not trivial at all because lists are a bit tricky to generate properly. It can be executed using our web service: http://w3id.org/sparql-generate/api/transform?queryurl=https://www.emse.fr/~zimmermann/Data/geojson/query-geojson.rqg You can play with the language using our online playground at: https://ci.mines-stetienne.fr/sparql-generate/playground.html but if you have a lot of data to convert, please use our executable JAR: https://ci.mines-stetienne.fr/sparql-generate/sparql-generate-jena.jar [1] RDF Mapping Language. http://rml.io/ [2] SPARQL-Generate. https://w3id.org/sparql-generate --AZ On 29/03/2018 21:17, Axel Polleres wrote: > Hi all, > > I have a question about LSON-LD to RDF conversion: > > > > Hi folks, > > I have a JSON-LD question: > > I was trying to use JSON-LD to convert nominatim's OSM output to RDF. > Essentially I tried adding a simple @context consisting of a simple @vocab namespace to the output of: > > https://nominatim.openstreetmap.org/reverse?osm_id=1990594&osm_type=R&polygon_geojson=1&format=json <https://nominatim.openstreetmap.org/reverse?osm_id=1990594&osm_type=R&polygon_geojson=1&format=json> > > in order to JSON-LDify it, arriving at this: > ``` > { > "@context": > { > "@vocab": "http://data.wu.ac.at/ns/osm_wrapper/" > }, > "licence":"Data © OpenStreetMap contributors, ODbL 1.0. https:\/\/osm.org\/copyright", "osm_type":"relation","osm_id":"1990594", "lat":"48.2006384", "lon":"16.426895311478","display_name":"Leopoldstadt, Wien, 1020, ?~Vsterreichh","address":{"city_district":"Leopoldstadt","city":"Wien","state":"Wien","postcode":"1020","country":"?~Vsterreich","country_code":"at"},"boundingbox":["48.1650897","48.2363475","16.3674575","16.4984617"],"geojson":{"type":"Polygon","coordinates":[[[16.3674575,48.2251075],[16.3675889,48.2248433],[16.3677014,48.2245416],[16.3678088,48.224167],[16.3678892,48.2236976],[16.3678804,48.2225512],[16.3679638,48.2215549],[16.3681553,48.2206543],[16.368354,48.2200858],[16.3685722,48.2197903],[16.3691878,48.2191461],[16.3696756,48.2187986],[16.3697005,48.2187537],[16.370149,48.2184891],[16.3705928,48.2181828],[16.3730586,48.2162786],[16.3735127,48.2158294],[16.3748503,48.2138968],[16.3750037,48.2136848],[16.3751909,48.213483],[16.375417,48.2132734],[16.3756681,48.213 0823],[16.3759558,48.2128966],[16.3762659,48.2127214],[16.3765444,48.2125783],[16.3767933,48.2124669],[16.3770396,48.2123689],[16.3773213,48.2122674],[16.3776787,48.2121566],[16.378046,48.2120631],[16.3785496,48.2119588],[16.3790386,48.2118721],[16.3795538,48.2117967],[16.3801144,48.2117366],[16.3810688,48.2116787],[16.3813019,48.2116741],[16.3815788,48.2116707],[16.3819552,48.2116759],[16.3824376,48.2116916],[16.3829286,48.2117265],[16.383917,48.2118198],[16.3840766,48.2118151],[16.3842505,48.2117642],[16.3844066,48.2116567],[16.3844793,48.211542],[16.3845071,48.2113936],[16.3848946,48.2113547],[16.3849036,48.2114232],[16.3849157,48.2114536],[16.3849313,48.2114786],[16.3849694,48.2115187],[16.3849941,48.2115334],[16.3850638,48.2117766],[16.3850918,48.2118472],[16.3851492,48.2119177],[16.3852455,48.211994],[16.3854257,48.2120648],[16.3860319,48.2122929],[16.3864832,48.2124664],[16.3865617,48.2125735],[16.3866417,48.2126365],[16.3868036,48.2127095],[16.3871675,48.2128421],[16.3875413, 48.2129527],[16.3879236,48.2130384],[16.3883691,48.2131175],[16.3888027,48.2131612],[16.3892349,48.2131825],[16.389647,48.213176],[16.3900579,48.2131492],[16.3903953,48.2131111],[16.3908259,48.213035],[16.3915326,48.2128909],[16.3923033,48.2126943],[16.3931358,48.2123726],[16.3937209,48.2120635],[16.3942561,48.2116641],[16.3946581,48.2112488],[16.3956534,48.2097274],[16.3961994,48.2087094],[16.3965158,48.2078611],[16.397082,48.2050464],[16.3973936,48.2044186],[16.3978408,48.2038574],[16.3983736,48.2034024],[16.398797,48.2030885],[16.3994891,48.2027366],[16.4003359,48.202475],[16.4039157,48.201825],[16.404979,48.2015825],[16.4058995,48.2012733],[16.4066582,48.2008865],[16.4073552,48.2003903],[16.4078547,48.1998829],[16.4085445,48.1989871],[16.4097751,48.1972113],[16.4100661,48.1968503],[16.4103604,48.1965465],[16.410865,48.1961194],[16.4118817,48.195365],[16.4134445,48.1943787],[16.4211488,48.1898533],[16.4220931,48.1893474],[16.4250996,48.1881121],[16.4301686,48.1866113],[16.4310992, 48.1863419],[16.4386107,48.1842029],[16.451663,48.1803481],[16.4605003,48.1777857],[16.4672414,48.1757468],[16.4677727,48.1755726],[16.4683386,48.175369],[16.4694852,48.174939],[16.4758724,48.1724605],[16.4784741,48.1712739],[16.4790301,48.1710463],[16.4797577,48.1707483],[16.4797281,48.1706977],[16.482739,48.1696294],[16.4838791,48.1691128],[16.4841719,48.1689849],[16.4844916,48.1688524],[16.4854739,48.1684853],[16.4860142,48.1683315],[16.4878399,48.1677592],[16.4898926,48.1671036],[16.4915066,48.1665412],[16.4930469,48.1659298],[16.4946226,48.1652865],[16.4946641,48.1653265],[16.4952282,48.1650897],[16.497085,48.1662737],[16.4984617,48.1671813],[16.4924117,48.1707639],[16.4885141,48.1731901],[16.4850516,48.1753516],[16.4791211,48.1791524],[16.4738454,48.1825645],[16.4507882,48.1978986],[16.4367364,48.2075131],[16.4297298,48.2124399],[16.4258648,48.2151612],[16.4228069,48.2174031],[16.4212773,48.2185006],[16.4178652,48.2209513],[16.4162691,48.2221101],[16.4155324,48.2226691],[16.408 6705,48.2278603],[16.4060609,48.2298632],[16.4037597,48.23167],[16.4016921,48.2333369],[16.3999414,48.2348052],[16.39813,48.2363475],[16.3952636,48.2348285],[16.3952714,48.2348175],[16.3900496,48.2320927],[16.386782,48.230365],[16.3879168,48.2293738],[16.3881888,48.2281683],[16.3880589,48.2280809],[16.3879758,48.2279555],[16.3879719,48.2278379],[16.3846792,48.2260733],[16.3833445,48.2256078],[16.3832679,48.2255949],[16.3831822,48.2256026],[16.383103,48.2256355],[16.3830495,48.225681],[16.3813009,48.2279149],[16.3804773,48.2283143],[16.3801322,48.2283067],[16.3798446,48.2284433],[16.379366,48.2286756],[16.3789703,48.2288677],[16.3776716,48.2294971],[16.3775195,48.2295707],[16.3766953,48.2292994],[16.3766339,48.2292792],[16.3762505,48.2291536],[16.3735354,48.2282613],[16.3721614,48.2278334],[16.3709455,48.2266748],[16.3709292,48.2266592],[16.3707049,48.2264456],[16.3704212,48.2261717],[16.3703725,48.2258255],[16.3697574,48.2256151],[16.3693506,48.225683],[16.368439,48.2253741],[16.3674 575,48.2251075]]]}} > ``` > > Now when I try to convert this JSON-LD to RDF (either using easyrdf.org [1] or te JSON-LD playground [2] I realize that what I get for the :coordinates property is just flattening all the values of the nested list into separate integer attribute values, in other words (illustrating in TTL syntax), I get back something like: > > -------- > > @prefix : <http://data.wu.ac.at/ns/osm_wrapper/ <http://data.wu.ac.at/ns/osm_wrapper/>> . > > ... > > [ :coordinates 1.636746e+1, 4.822511e+1, 1.636759e+1, 4.822484e+1, 1.636770e+1, 4.822454e+1, 1.636781e+1, 4.822417e+1, 1.636789e+1, 4.822370e+1, 1.636788e+1, 4.822255e+1, 1.636796e+1, > > ... > > ] > > ------ > > This is of course not ideal, as it looses the structure of the nested list... is this *seriously* what JSON-LDs model is prescribing? Anyway, can redefine the context to influence that handling of nested list attributes? > Or is this simply a bug? > > hints/opinions welcome! > > Axel > > > 1. http://www.easyrdf.org/ > 2. https://json-ld.org/playground/ > > > > -- > Dr. Axel Polleres > url: http://www.polleres.net/ twitter: @AxelPolleres > >
Received on Friday, 30 March 2018 08:29:46 UTC