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

Importing N-triples requires quotes to be double escaped #288

Open
danmichaelo opened this issue Dec 19, 2022 · 4 comments
Open

Importing N-triples requires quotes to be double escaped #288

danmichaelo opened this issue Dec 19, 2022 · 4 comments

Comments

@danmichaelo
Copy link

danmichaelo commented Dec 19, 2022

Seems like there is an issue with importing strings with escaped quotes (\"):

CALL n10s.graphconfig.init({
  handleVocabUris: 'IGNORE',
  handleMultival: 'OVERWRITE',
  handleRDFTypes: 'LABELS',
  applyNeo4jNaming: true
});

CALL n10s.rdf.import.inline(
  '
<https://example.org/thing/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/prop/Event> .

<https://example.org/thing/1> <https://example.org/prop/name> "Test \"with\" quotes" .
',
  'N-Triples' 
)
terminationStatus triplesLoaded triplesParsed namespaces extraInfo callParams
KO 0 0   Content after '.' is not allowed [line 2] {}

It works if I double-escape them:

CALL n10s.rdf.import.inline(
  '
<https://example.org/thing/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://id.bs.no/cordata/class/Event> .

<https://example.org/thing/1> <https://example.org/prop/name> "Test \\"with\\" quotes" .
',
  'N-Triples' 
)

but that's not standard in the n-triples serialization, I think.

@danmichaelo danmichaelo changed the title Importing N-triples with quotes requires double escaping Importing N-triples requires quotes to be double escaped Dec 19, 2022
@danmichaelo
Copy link
Author

Note: This only seems to be a problem with the inline import – importing from a file with n10s.rdf.import.fetch works fine with single escaped quotes!

@jbarrasa
Copy link
Collaborator

Hi @danmichaelo ,
I think the behavior is consistent. When you use the .inline method you need to pass a parseable string so additional escaping is needed.
Let me use a simple example in python that shows the strings we are passing to the method in each case:

this_will_fail_parsing = '\"Test \"with\" quotes\"'
print('this_will_fail_parsing: ',this_will_fail_parsing)

>>  this_will_fail_parsing:  "Test "with" quotes"



this_will_parse = '\"Test \\"with\\" quotes\"'
print('this_will_parse: ', this_will_parse)

>>  this_will_parse:  "Test \"with\" quotes"

do you agree?

JB.

@danmichaelo
Copy link
Author

Thanks, that makes sense, @jbarrasa 🙌 I was probably confused because I pasted N-triples into the "Import Data" dialog in Neosemantics and it didn't convert them:

image

Perhaps the real issue, if there is one, is with how the import dialog works? I think it could be argued that the import dialog should accept normal RDF input (single escaped quotes) and convert it to valid Cypher automatically? What do you think?

Sorry for the confusion btw.! Feel free to rename the issue or close it accordingly 👍

@jbarrasa
Copy link
Collaborator

Oh! I see what you mean.
You're totally right, the app should take care of the escaping and produce valid cypher, for sure.
I thought you were working on the browser, that's why I suggested it was up to you to generate a correct string.

Let us have a look at that, and thanks for explaining it in detail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants