Giter VIP home page Giter VIP logo

Comments (4)

filip26 avatar filip26 commented on August 19, 2024

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.

jmvanel avatar jmvanel commented on August 19, 2024

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.

filip26 avatar filip26 commented on August 19, 2024

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.

jmvanel avatar jmvanel commented on August 19, 2024

The processing chain here is quite long:

  1. getting a SPARQL query in Jena TDB, including blank nodes
  2. converting to Titanium RDF Dataset
  3. running JsonLd.fromRdf()
  4. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.