-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test serialization of GND RDF to compact JSON-LD
See #1
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ target | |
.classpath | ||
.project | ||
.settings/org.scala-ide.sdt.core.prefs | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package controllers; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerationException; | ||
import com.github.jsonldjava.core.JsonLdError; | ||
import com.github.jsonldjava.core.JsonLdOptions; | ||
import com.github.jsonldjava.core.JsonLdProcessor; | ||
import com.github.jsonldjava.jena.JenaRDFParser; | ||
import com.github.jsonldjava.utils.JsonUtils; | ||
import com.hp.hpl.jena.rdf.model.Model; | ||
import com.hp.hpl.jena.rdf.model.ModelFactory; | ||
|
||
public class TestRdfSerialization { | ||
|
||
public static void main(String[] args) throws JsonLdError, JsonGenerationException, IOException { | ||
Model model = ModelFactory.createDefaultModel(); | ||
model.read("http://d-nb.info/gnd/2047974-8/about/lds"); | ||
Object jsonLd = JsonLdProcessor.fromRDF(model, new JenaRDFParser()); | ||
String context = "http://hub.culturegraph.org/entityfacts/context/v1/entityfacts.jsonld"; | ||
JsonLdOptions options = new JsonLdOptions(); | ||
options.setCompactArrays(false); | ||
jsonLd = JsonLdProcessor.compact(jsonLd, context, options); | ||
System.out.println(JsonUtils.toPrettyString(jsonLd)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters