Skip to content
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

triples with aliased @id and @base are missing at root level #61

Closed
jmvanel opened this issue Aug 6, 2020 · 7 comments · Fixed by #74 or #76
Closed

triples with aliased @id and @base are missing at root level #61

jmvanel opened this issue Aug 6, 2020 · 7 comments · Fixed by #74 or #76
Assignees
Milestone

Comments

@jmvanel
Copy link
Contributor

jmvanel commented Aug 6, 2020

Describe the bug
Two triples corresponding to @id "id" : "54141546" at root level in the JSON are lost.
Both @id 's are associated to a @base .
So there is just one triple left, corresponding to the inner JSON block :

<https://www.inaturalist.org/users/3295956>
  <http://xmlns.com/foaf/0.1/img> 
    <https://static.inaturalist.org/attachments/users/icons/3295956/thumb.jpg?1594113662>

(works fine with Distiller & JS-LD Playground)

To Reproduce
Prepare files

echo '{
  "uri" : "54141546" ,
  "description" : "Aucune fleur ou fruit, glauque",
  "user" : {
    "id" : "3295956",
    "icon" : "https://static.inaturalist.org/attachments/users/icons/3295956/thumb.jpg?1594113662"
  } }' > test-bug-OK.json
echo '{ "@context": {
  "foaf": "http://xmlns.com/foaf/0.1/",
  "rdfs" : "http://www.w3.org/2000/01/rdf-schema#" ,
  "@base" : "https://api.inaturalist.org/v1/observations/" ,  
  "uri": "@id",
  "description" : "rdfs:comment" ,
  "user" : {
     "@id": "foaf:maker",
     "@context": {
      "icon" : { "@id": "foaf:img", "@type": "@id" } ,
      "@base" : "https://www.inaturalist.org/users/" ,
      "id" : "@id"
    }
  }
} }' > test-bug.context-OK.jsonld

Java code

String dir = "file:////home/jmv/test/"
String uri = dir + "test-bug-OK.json";
String context = dir + "test-bug.context-OK.jsonld";
JsonLdOptions options = new JsonLdOptions();
options.setExpandContext(context);
System.println(  JsonLd.toRdf( uri ) . options(options) . get() )

Expected behavior
Like with Distiller:

<https://api.inaturalist.org/v1/observations/54141546> <http://xmlns.com/foaf/0.1/maker> <https://www.inaturalist.org/users/3295956> .
<https://api.inaturalist.org/v1/observations/54141546> <http://www.w3.org/2000/01/rdf-schema#comment> "Aucune fleur ou fruit, glauque" .
<https://www.inaturalist.org/users/3295956> <http://xmlns.com/foaf/0.1/img> <https://static.inaturalist.org/attachments/users/icons/3295956/thumb.jpg?1594113662> 

Additional context
NOTE : to be able to test I commented out the faulty Java code that prevents use of file: URL's , see preceding issue .

@jmvanel jmvanel changed the title "id" is not kept at root level (works with JS-LD Playground) triples with id are missing at root level Aug 6, 2020
@jmvanel jmvanel changed the title triples with id are missing at root level triples with id and @base are missing at root level Aug 6, 2020
@jmvanel jmvanel changed the title triples with id and @base are missing at root level triples with aliased @id and @base are missing at root level Aug 6, 2020
@filip26 filip26 self-assigned this Aug 28, 2020
filip26 added a commit that referenced this issue Aug 28, 2020
filip26 added a commit that referenced this issue Aug 28, 2020
@filip26 filip26 added the bug Something isn't working label Aug 28, 2020
@filip26
Copy link
Owner

filip26 commented Aug 28, 2020

possibly fixed by #68

@filip26 filip26 added this to the 0.8.5 milestone Aug 28, 2020
filip26 added a commit that referenced this issue Aug 28, 2020
@filip26
Copy link
Owner

filip26 commented Aug 28, 2020

@jmvanel please verify, the attached test passes. thank you.

@jmvanel
Copy link
Contributor Author

jmvanel commented Aug 29, 2020

@jmvanel please verify, the attached test passes. thank you.

Alas, no, the original problem remains.
I saw you added the data of original issue as a test, but the test suite says:

Tests run: 1890, Failures: 0, Errors: 0, Skipped: 271

@filip26
Copy link
Owner

filip26 commented Aug 29, 2020

I'm sorry, but I cannot reproduce the issue. I run the test manually as well. Please feel free to update test 61

(the test suite includes 1.0 tests and non-normative tests (the skipped ones).

jmvanel added a commit to jmvanel/titanium-json-ld that referenced this issue Aug 29, 2020
…d file: URL's

NOTE:
The 2 added tests are with expanded context. I don't know whether the plain context and the expanded context are different things for ToRDF().
@filip26
Copy link
Owner

filip26 commented Aug 29, 2020

thank you, There is something wrong if a context is referenced by URI.

btw. you can use this to print RdfDataset to System.out

(new NQuadsWriter(new PrintWriter(System.out))).write(result);

@filip26
Copy link
Owner

filip26 commented Aug 29, 2020

The issue is that @base is not processed if a context is remote, it's related to issue #63

A workaround is to set the base manually. e.g.

JsonLd.toRdf("file:/...").context("file:/...").base("https://api.inaturalist.org/v1/observations/").get()

@filip26
Copy link
Owner

filip26 commented Aug 29, 2020

The specification states:

If context is a string, it represents a reference to a remote context. 
...
Please note that @base is ignored when processing remote contexts.

See 4.1.1 Overview

and

If the expandContext option in options is set, update the active context using 
the Context Processing algorithm, passing the expandContext as local context

See expand() 6.

In your case an array containing one URL (the file:/... represented as a string) is passed to Context Processing algorithm as a local context and is processed by a step 5.2.

Question about base and remote contexts suggests to remove @base after step 5.2.5.2 which is a step right after the given URL has been deferrenced.

I tend to close this issue and recommend to set a base explicitly as suggested above, please feel to re-open, to put more light on this.

filip26 added a commit that referenced this issue Aug 30, 2020
@filip26 filip26 linked a pull request Aug 30, 2020 that will close this issue
filip26 added a commit that referenced this issue Aug 30, 2020
@filip26 filip26 removed the bug Something isn't working label Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants