Comments (4)
Hi @jmvanel ,
thank you for reporting this.
Please help me prepare a test case. I understand that you do fromRdf
transformation and then you apply frame
transformation on the result . Not sure which transformation is erroneous, maybe both.
I can download the GeoJSON-LD context but it would be very helpful if you can provide an example of RDF input that produces the wrong result.
FYI: I've noticed a couple of things in your code:
here is duplicated code - line 118
the GeoJSON-LD context is passed as a frame, not as a context
Best regards,
Filip
from titanium-json-ld.
I provide a simpler example, only JSON-LD input on frame algorithm, that produces the wrong result.
P.S. Did not understand your comment "the GeoJSON-LD context is passed as a frame, not as a context"
package jmvanel;
import java.io.FileWriter;
import java.io.IOException;
import com.apicatalog.jsonld.JsonLd;
import com.apicatalog.jsonld.document.Document;
import com.apicatalog.jsonld.document.DocumentParser;
import com.apicatalog.jsonld.http.media.MediaType;
import java.io.StringReader;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonWriter;
import com.apicatalog.jsonld.api.JsonLdError;
import com.apicatalog.jsonld.api.JsonLdOptions;
/** - read expanded JSON-LD
* - frame with GEOJSON context */
public class GeoJSONexportTest {
static String jsonInputExpanded = "[\n" +
" {\n" +
" \"@id\": \"https://semantic-forms.cc:1953/ldp/1532706288331-48387235120480835\",\n" +
" \"https://purl.org/geojson/vocab#properties\": [\n" +
" {\n" +
" \"@id\": \"f8c50b76-83d0-4cf1-ac6d-ec620eaeb449\"\n" +
" }\n" +
" ],\n" +
" \"https://purl.org/geojson/vocab#geometry\": [\n" +
" {\n" +
" \"@id\": \"e01148c8-2148-4ae4-b6e3-5c941a299ce9\"\n" +
" }\n" +
" ],\n" +
" \"@type\": [\n" +
" \"https://purl.org/geojson/vocab#Feature\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"@id\": \"e01148c8-2148-4ae4-b6e3-5c941a299ce9\",\n" +
" \"https://purl.org/geojson/vocab#coordinates\": [\n" +
" {\n" +
" \"@id\": \"a61c31ed-1375-43a5-b875-fb2079213265\"\n" +
" }\n" +
" ],\n" +
" \"@type\": [\n" +
" \"https://purl.org/geojson/vocab#Point\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"@id\": \"a61c31ed-1375-43a5-b875-fb2079213265\",\n" +
" \"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest\": [\n" +
" {\n" +
" \"@id\": \"44c4e184-7fdf-48f6-8f97-943623fdcc52\"\n" +
" }\n" +
" ],\n" +
" \"http://www.w3.org/1999/02/22-rdf-syntax-ns#first\": [\n" +
" {\n" +
" \"@value\": \"0.9016695\"\n" +
" }\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"@id\": \"44c4e184-7fdf-48f6-8f97-943623fdcc52\",\n" +
" \"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest\": [\n" +
" {\n" +
" \"@list\": []\n" +
" }\n" +
" ],\n" +
" \"http://www.w3.org/1999/02/22-rdf-syntax-ns#first\": [\n" +
" {\n" +
" \"@value\": \"46.8332179\"\n" +
" }\n" +
" ]\n" +
" }\n" +
"]\n" +
"";
static String jsonInput = jsonInputExpanded;
// From https://geojson.org/geojson-ld/geojson-context.jsonld
static String geojsonContext = "{ \"@context\": {\n" +
" \"geojson\": \"https://purl.org/geojson/vocab#\",\n" +
" \"Feature\": \"geojson:Feature\",\n" +
" \"FeatureCollection\": \"geojson:FeatureCollection\",\n" +
" \"GeometryCollection\": \"geojson:GeometryCollection\",\n" +
" \"LineString\": \"geojson:LineString\",\n" +
" \"MultiLineString\": \"geojson:MultiLineString\",\n" +
" \"MultiPoint\": \"geojson:MultiPoint\",\n" +
" \"MultiPolygon\": \"geojson:MultiPolygon\",\n" +
" \"Point\": \"geojson:Point\",\n" +
" \"Polygon\": \"geojson:Polygon\",\n" +
" \"bbox\": {\n" +
" \"@container\": \"@list\",\n" +
" \"@id\": \"geojson:bbox\"\n" +
" },\n" +
" \"coordinates\": {\n" +
" \"@container\": \"@list\",\n" +
" \"@id\": \"geojson:coordinates\"\n" +
" },\n" +
" \"features\": {\n" +
" \"@container\": \"@set\",\n" +
" \"@id\": \"geojson:features\"\n" +
" },\n" +
" \"geometry\": \"geojson:geometry\",\n" +
" \"id\": \"@id\",\n" +
" \"properties\": \"geojson:properties\",\n" +
" \"type\": \"@type\"\n" +
" }\n" +
" }";
static String fileName = "out.test.geojson";
public static void main(String[] args) throws JsonLdError, IOException {
// String url = "https://geojson.org/geojson-ld/geojson-context.jsonld";
FileWriter fw = new FileWriter(fileName);
JsonLdOptions options = new JsonLdOptions();
options.setUseNativeTypes(true);
options.setOmitGraph(true);
options.setCompactToRelative(true);
options.setUseNativeTypes(true);
Document contextDocument = makeJSONLDdocument(geojsonContext);
Document jsonDoc = makeJSONLDdocument(jsonInput);
JsonObject jsonObject = JsonLd.frame(jsonDoc, contextDocument).options(options).get();
JsonWriter jsonWriter = Json.createWriter(fw);
jsonWriter.writeObject(jsonObject);
jsonWriter.close();
}
static Document makeJSONLDdocument(String src) throws JsonLdError {
StringReader inputStream = new StringReader(src);
return DocumentParser.parse(MediaType.JSON_LD, inputStream);
}
}
from titanium-json-ld.
I'm sorry but I cannot reproduce the issue (tested against latest code base - 0.8.6-SNAPSHOT). The provided test produces the same output as json-ld playground.
from titanium-json-ld.
The processing chain here is quite long:
- getting a SPARQL query in Jena TDB, including blank nodes
- converting to Titanium RDF Dataset
- running JsonLd.fromRdf()
- running JsonLd.frame()
and in the end, the JSON array corresponding to RDF list is not present.
I finally found the location of error, in step 3, giving this issue : #118
So I can close the issue :) .
from titanium-json-ld.
Related Issues (20)
- JsonLd->NQuads->JsonLd value type format mismatch HOT 2
- DefaultHttpLoader creates invalid accept header HOT 2
- Expose the prefixes found in the top level @context, including remote @context. HOT 10
- 1.1.1 release? HOT 2
- Issue with framing (flattening) and @reverse in @context. HOT 1
- Library compatibility when non well-formed DIDs are present HOT 8
- benchmark titanium against jsonld-java HOT 5
- Simplify JSON data checks HOT 1
- Improve JsonLd.compact and JsonLd.frame method overloading
- Fix NPEs in *Api.base(null) HOT 1
- Fix FromRdf processor loading error message HOT 1
- Support language private subtags HOT 1
- How to load multiple contexts from local reference HOT 1
- Asynchronous Document Loader HOT 1
- Some URI resources are resolving as strings rather than URI HOT 2
- Provide a multi-release jar? HOT 14
- Allow to set custom DocumentResolver HOT 2
- Usage of @reverse breaks scoped contexts HOT 8
- Frame aliasing `@graph` broken when `omitGraph = false` HOT 4
- Add benchmarks HOT 1
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 titanium-json-ld.