-
Notifications
You must be signed in to change notification settings - Fork 202
Bug/support nquads #148
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
Closed
Closed
Bug/support nquads #148
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dcf2f12
Support standard application/n-quads in jsonld
ivikash 9c9533c
Parameters in options fixed
ivikash c207508
README.md changes
ivikash cce2b89
application/nquads changed to application/n-quads
ivikash 024a700
Removed comments
ivikash bce8be7
Comments for N-Quads fixed
ivikash c4e3db5
Changed nquads --> n-quads in inputFormat
ivikash d081290
Typo fixed for n-quads
ivikash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -756,9 +756,9 @@ jsonld.objectify = function(input, ctx, options, callback) { | |
* [base] the base IRI to use. | ||
* [expandContext] a context to expand with. | ||
* [inputFormat] the format if input is not JSON-LD: | ||
* 'application/nquads' for N-Quads. | ||
* 'application/nquads' or 'application/n-quads' for N-Quads. | ||
* [format] the format if output is a string: | ||
* 'application/nquads' for N-Quads. | ||
* 'application/nquads' or 'application/n-quads' for N-Quads. | ||
* [documentLoader(url, callback(err, remoteDoc))] the document loader. | ||
* @param callback(err, normalized) called once the operation completes. | ||
*/ | ||
|
@@ -788,7 +788,7 @@ jsonld.normalize = function(input, options, callback) { | |
} | ||
|
||
if('inputFormat' in options) { | ||
if(options.inputFormat !== 'application/nquads') { | ||
if((options.inputFormat !== 'application/nquads') || (options.inputFormat !== 'application/n-quads')) { | ||
return callback(new JsonLdError( | ||
'Unknown normalization input format.', | ||
'jsonld.NormalizeError')); | ||
|
@@ -821,6 +821,8 @@ jsonld.normalize = function(input, options, callback) { | |
* @param [options] the options to use: | ||
* [format] the format if dataset param must first be parsed: | ||
* 'application/nquads' for N-Quads (default). | ||
* [useStandardNQuadsType] the format of N-Quads | ||
* (default: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this option. All we're really doing is correcting for what could now be seen as a typo ... so if someone uses |
||
* [rdfParser] a custom RDF-parser to use to parse the dataset. | ||
* [useRdfType] true to use rdf:type, false to use @type | ||
* (default: false). | ||
|
@@ -850,10 +852,18 @@ jsonld.fromRDF = function(dataset, options, callback) { | |
options.useNativeTypes = false; | ||
} | ||
|
||
if (!('useStandardNQuadsType' in options)){ | ||
options.useStandardNQuadsType = false; | ||
} | ||
|
||
if(!('format' in options) && _isString(dataset)) { | ||
// set default format to nquads | ||
if(!('format' in options)) { | ||
options.format = 'application/nquads'; | ||
if (!options.useStandardNQuadsType){ | ||
options.format = 'application/nquads'; | ||
} else { | ||
options.format = 'application/n-quads'; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -959,7 +969,7 @@ jsonld.toRDF = function(input, options, callback) { | |
// output RDF dataset | ||
dataset = Processor.prototype.toRDF(expanded, options); | ||
if(options.format) { | ||
if(options.format === 'application/nquads') { | ||
if((options.format === 'application/nquads') || (options.format === 'application/n-quads')) { | ||
return callback(null, _toNQuads(dataset)); | ||
} | ||
throw new JsonLdError( | ||
|
@@ -4217,7 +4227,7 @@ Normalize.prototype.main = function(dataset, callback) { | |
normalized.sort(); | ||
|
||
// 8) Return the normalized dataset. | ||
if(self.options.format === 'application/nquads') { | ||
if((self.options.format === 'application/nquads') || (self.options.format === 'application/n-quads')) { | ||
result = normalized.join(''); | ||
return callback(); | ||
} | ||
|
@@ -7023,6 +7033,7 @@ function _parseNQuads(input) { | |
|
||
// register the N-Quads RDF parser | ||
jsonld.registerRDFParser('application/nquads', _parseNQuads); | ||
jsonld.registerRDFParser('application/n-quads', _parseNQuads); | ||
|
||
/** | ||
* Converts an RDF dataset to N-Quads. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be an
&&
? Otherwise it would seem that this compound conditional would always be true.That being said, it would probably be cleaner to make a shallow copy of the options and if the
inputFormat
isapplication/nquads
it should just be changed early to the correctapplication/n-quads
. Then we only need to check for that in the code later. So let's normalize toapplication/n-quads
.