From 7eb4e8d4de99afaee0055832da235c79adf88243 Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Tue, 27 May 2025 09:51:33 +0200 Subject: [PATCH 1/8] fixed langauge, and type issue for parsing to nquads --- src/knowledge-collection-tools.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/knowledge-collection-tools.js b/src/knowledge-collection-tools.js index 917e605..646a32f 100644 --- a/src/knowledge-collection-tools.js +++ b/src/knowledge-collection-tools.js @@ -234,7 +234,7 @@ export function groupNquadsBySubject(nquadsArray, sort = false) { const grouped = {}; parser.parse(nquadsArray.join("")).forEach((quad) => { - const { subject, predicate, object } = quad; + const { subject } = quad; let subjectKey; if (subject.termType === "Quad") { @@ -242,8 +242,8 @@ export function groupNquadsBySubject(nquadsArray, sort = false) { const nestedPredicate = subject.predicate.value; const nestedObject = subject.object.termType === "Literal" - ? `"${escapeLiteral(subject.object.value)}"` - : `<${escapeLiteral(subject.object.value)}>`; + ? `"${subject.object.value}"` + : `<${subject.object.value}>`; subjectKey = `<<<${nestedSubject}> <${nestedPredicate}> ${nestedObject}>>`; } else { subjectKey = `<${subject.value}>`; @@ -253,12 +253,14 @@ export function groupNquadsBySubject(nquadsArray, sort = false) { grouped[subjectKey] = []; } - const objectValue = - object.termType === "Literal" - ? `"${escapeLiteral(object.value)}"` - : `<${escapeLiteral(object.value)}>`; + const writer = new N3.Writer({ format: "N-Quads" }); + let quadString = ""; + writer.addQuad(quad); + writer.end((error, result) => { + if (error) throw error; + quadString = result.trim(); + }); - const quadString = `${subjectKey} <${predicate.value}> ${objectValue} .`; grouped[subjectKey].push(quadString); }); From dc791414cf0709c1a27095eacf8a19803a9932ea Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Wed, 28 May 2025 15:27:23 +0200 Subject: [PATCH 2/8] added groupNquadsBySubject tests --- test/knowledge-collection-tools.test.js | 201 ++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 9 deletions(-) diff --git a/test/knowledge-collection-tools.test.js b/test/knowledge-collection-tools.test.js index 02324eb..96d1b2e 100644 --- a/test/knowledge-collection-tools.test.js +++ b/test/knowledge-collection-tools.test.js @@ -122,19 +122,202 @@ describe("calculateMerkleProof", () => { }); describe("groupNquadsBySubject", () => { - it("should group quads by a single subject", () => { + it("should group quads where the object is a resource", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "author": { + "@id": "http://example.org/author1" + } + } + */ const quads = [ - " .", - ' "Literal" .', + " .", + " .", ]; + const grouped = groupNquadsBySubject(quads); expect(grouped).to.have.lengthOf(1); - expect(grouped[0]).to.deep.include( - " ." - ); - expect(grouped[0]).to.deep.include( - ' "Literal" .' - ); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + }); + + it("should group quads where the object is a literal", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "title": "The Great Book" + } + */ + const quads = [ + ' "The Great Book" .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + }); + + it("should group quads where the object is a literal containing an escape character", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "title": "The Great Book \n" + } + */ + const quads = [ + // \n is represented as \\n in code + ' "The Great Book \\n" .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + }); + + it("should group quads where the object is a typed literal", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "publicationDate": { + "@value": "2025-05-28", + "@type": "http://www.w3.org/2001/XMLSchema#date" + } + } + */ + const quads = [ + ' "2025-05-28"^^ .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + }); + + it("should group quads where the object is a typed literal that includes an escape character", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "publicationDate": { + "@value": "2025-05-28 \n", + "@type": "http://www.w3.org/2001/XMLSchema#date" + } + } + */ + const quads = [ + // \n is represented as \\n in code + ' "2025-05-28 \\n"^^ .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + }); + + it("should group quads where the object is a literal with language defined", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "description": [ + { + "@value": "A thrilling adventure novel.", + "@language": "en" + }, + { + "@value": "Napeta pustolovska novela.", + "@language": "sl" + } + ] + } + */ + const quads = [ + ' "A thrilling adventure novel."@en .', + ' "Napeta pustolovska novela."@sl .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + expect(grouped[0]).to.deep.include(quads[2]); + }); + + it("should group quads where the object is a literal with language defined, containing an escape character", () => { + /* JSON-LD + { + "@context": "http://schema.org", + "@id": "http://example.org/book1", + "type": "Book", + "description": [ + { + "@value": "A thrilling adventure novel. \n", + "@language": "en" + }, + { + "@value": "Napeta pustolovska novela. \n", + "@language": "sl" + } + ] + } + */ + const quads = [ + // \n is represented as \\n in code + ' "A thrilling adventure novel. \\n"@en .', + ' "Napeta pustolovska novela. \\n"@sl .', + ' .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); + expect(grouped[0]).to.deep.include(quads[1]); + expect(grouped[0]).to.deep.include(quads[2]); + }); + + it("should group quads where the object is a literal with language defined, while subject is a blank node", () => { + /* JSON-LD + { + "@context": { + "predicate": "http://example.org/predicate" + }, + "@graph": [ + { + "predicate": { + "@value": "something", + "@language": "en" + } + } + ] + } + */ + const quads = [ + ' "something"@en .', + ]; + + const grouped = groupNquadsBySubject(quads); + expect(grouped).to.have.lengthOf(1); + expect(grouped[0]).to.deep.include(quads[0]); }); it("should group quads by multiple subjects", () => { From 61c053fd35c37fc30e3e643d8e7df49c63bb5364 Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 09:20:04 +0200 Subject: [PATCH 3/8] removed the escapeLiteral function --- src/knowledge-collection-tools.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/knowledge-collection-tools.js b/src/knowledge-collection-tools.js index 646a32f..d2cf90b 100644 --- a/src/knowledge-collection-tools.js +++ b/src/knowledge-collection-tools.js @@ -404,17 +404,3 @@ Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all function isEmptyObject(obj) { return Object.keys(obj).length === 0 && obj.constructor === Object; } - -function escapeLiteral(value) { - const ESCAPE_MAP = { - '"': '\\"', - "\\": "\\\\", - "\b": "\\b", - "\f": "\\f", - "\n": "\\n", - "\r": "\\r", - "\t": "\\t", - }; - - return value.replace(/["\\\b\f\n\r\t]/g, (char) => ESCAPE_MAP[char]); -} From ea7258ecff2760b3fdb46ddebbd8f37654aae95e Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 12:47:58 +0200 Subject: [PATCH 4/8] added generateMissingIdsForBlankNodes tests --- test/knowledge-collection-tools.test.js | 339 ++++++++++++++++++++++++ 1 file changed, 339 insertions(+) diff --git a/test/knowledge-collection-tools.test.js b/test/knowledge-collection-tools.test.js index 96d1b2e..040e49f 100644 --- a/test/knowledge-collection-tools.test.js +++ b/test/knowledge-collection-tools.test.js @@ -1,4 +1,6 @@ import { describe, it } from "mocha"; + import fs from 'fs'; +import N3 from 'n3'; import { expect } from "chai"; import { formatDataset, @@ -531,4 +533,341 @@ describe("generateMissingIdsForBlankNodes", () => { ) ); }); + + it("should replace an object blank node", () => { + /* + JSON-LD + { + "@context": { + "relatedTo": "http://example.org/relatedTo" + }, + "@id": "http://example.org/document/1", + "relatedTo": {} + } + */ + const nquadsArray = [ + " _:c14n0 .", + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + expect(quads[0]._subject.id).equals('http://example.org/document/1'); + + expect(quads[0]._predicate.id).equals('http://example.org/relatedTo'); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + expect(quads[0]._object.id.match(uuidRegex)); + + expect(quads[0]._graph.id).equals(''); + }); + + it("should replace an occuring object blank node", () => { + /* + JSON-LD + { + "@context": { + "is": {"@id": "http://example.org/is"} + }, + "@graph": [ + { + "@id": "http://example.org/subject1", + "is": {"@id": "_:sharedBlank"} + }, + { + "@id": "http://example.org/subject2", + "is": {"@id": "_:sharedBlank"} + } + ] + } + */ + const nquadsArray = [ + " _:c14n0 .", + " _:c14n0 .", + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + expect(quads[0]._subject.id).equals('http://example.org/subject1'); + expect(quads[1]._subject.id).equals('http://example.org/subject2'); + + expect(quads[0]._predicate.id).equals('http://example.org/is'); + expect(quads[1]._predicate.id).equals('http://example.org/is'); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + + expect(quads[0]._object.id.match(uuidRegex)); + expect(quads[1]._object.id.match(uuidRegex)); + + expect(quads[0]._graph.id).equals(''); + expect(quads[1]._graph.id).equals(''); + + expect(quads[0]._object.id).equals(quads[1]._object.id); + }); + + it("should replace a subject blank node", () => { + /* + JSON-LD + { + "@context": { + "ex": "http://example.org/" + }, + "@graph": [ + { + "ex:name": "John Doe" + } + ] + } + */ + const nquadsArray = [ + '_:c14n0 "John Doe" .', + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + expect(quads[0]._subject.id.match(uuidRegex)); + + expect(quads[0]._predicate.id).equals('http://example.org/name'); + + expect(quads[0]._object.id).equals('"John Doe"'); + + expect(quads[0]._graph.id).equals(''); + }); + + it("should replace an occuring subject blank node", () => { + /* + JSON-LD + { + "@context": { + "ex": "http://example.org/" + }, + "@graph": [ + { + "ex:name": "John Doe", + "ex:sex": "male" + } + ] + } + */ + const nquadsArray = [ + '_:c14n0 "John Doe" .', + '_:c14n0 "male" .', + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + expect(quads[0]._subject.id.match(uuidRegex)); + expect(quads[1]._subject.id.match(uuidRegex)); + + expect(quads[0]._predicate.id).equals('http://example.org/name'); + expect(quads[1]._predicate.id).equals('http://example.org/sex'); + + expect(quads[0]._object.id).equals('"John Doe"'); + expect(quads[1]._object.id).equals('"male"'); + + expect(quads[0]._graph.id).equals(''); + expect(quads[1]._graph.id).equals(''); + + expect(quads[0]._subject.id).equals(quads[1]._subject.id); + }); + + it("should not replace two different subject blank node with the same UUID", () => { + /* + JSON-LD + { + "@context": { + "ex": "http://example.org/" + }, + "@graph": [ + { + "ex:hasName": "Alice", + "ex:sex": "male" + }, + { + "ex:hasName": "Bob", + "ex:sex": "female" + } + ] + } + */ + const nquadsArray = [ + '_:c14n0 "male" .', + '_:c14n0 "Bob" .', + '_:c14n1 "female" .', + '_:c14n1 "Alice" .', + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + expect(quads[0]._subject.id.match(uuidRegex)); + expect(quads[1]._subject.id.match(uuidRegex)); + expect(quads[2]._subject.id.match(uuidRegex)); + expect(quads[3]._subject.id.match(uuidRegex)); + + expect(quads[0]._predicate.id).equals('http://example.org/sex'); + expect(quads[1]._predicate.id).equals('http://example.org/hasName'); + expect(quads[2]._predicate.id).equals('http://example.org/sex'); + expect(quads[3]._predicate.id).equals('http://example.org/hasName'); + + expect(quads[0]._object.id).equals('"male"'); + expect(quads[1]._object.id).equals('"Bob"'); + expect(quads[2]._object.id).equals('"female"'); + expect(quads[3]._object.id).equals('"Alice"'); + + expect(quads[0]._graph.id).equals(''); + expect(quads[1]._graph.id).equals(''); + expect(quads[2]._graph.id).equals(''); + expect(quads[3]._graph.id).equals(''); + + expect(quads[0]._subject.id).equals(quads[1]._subject.id); + expect(quads[2]._subject.id).equals(quads[3]._subject.id); + expect(quads[0]._subject.id).not.equals(quads[2]._subject.id); + }); + + it("should replace an object blank node, that occurs as a subject, with the same UUID", () => { + /* + JSON-LD + { + "@context": "http://schema.org", + "review": { + "reviewBody": "Excellent book!" + } + } + */ + const nquadsArray = [ + '_:c14n0 "Excellent book!" .', + "_:c14n1 _:c14n0 .", + ]; + + const updatedQuads = generateMissingIdsForBlankNodes(nquadsArray); + + const parser = new N3.Parser(); + const quads = parser.parse(updatedQuads.join('\n')); + + const uuidRegex = /^uuid:[0-9a-fA-F\-]{36}$/; + expect(quads[0]._subject.id.match(uuidRegex)); + expect(quads[1]._subject.id.match(uuidRegex)); + + expect(quads[0]._predicate.id).equals('http://schema.org/reviewBody'); + expect(quads[1]._predicate.id).equals('http://schema.org/review'); + + expect(quads[0]._object.id).equals('"Excellent book!"'); + expect(quads[1]._object.id.match(uuidRegex)); + + expect(quads[0]._graph.id).equals(''); + expect(quads[1]._graph.id).equals(''); + + + expect(quads[0]._subject.id).not.equals(quads[1]._subject.id); + expect(quads[0]._subject.id).equals(quads[1]._object.id); + }); + + it("should fail since graphs aren't supported at this stage", () => { + /* + JSON-LD + { + "@context": { + "@base": "https://example.org/", + "name": "http://schema.org/name", + "knows": { + "@id": "http://schema.org/knows", + "@type": "@id" + }, + "Person": "http://schema.org/Person" + }, + "@graph": [ + { + "@type": "Person", + "name": "Alice", + "knows": [ + { + "@id": "_:bob" + }, + { + "@id": "_:carol" + } + ] + }, + { + "@id": "_:bob", + "@graph": [ + { + "@type": "Person", + "name": "Bob" + } + ] + }, + { + "@id": "_:carol", + "@graph": [ + { + "@type": "Person", + "name": "Carol" + } + ] + } + ] + } + */ + const nquadsArray = [ + '_:c14n2 "Carol" _:c14n0 .', + '_:c14n2 _:c14n0 .', + '_:c14n3 _:c14n0 .', + '_:c14n3 _:c14n1 .', + '_:c14n3 "Alice" .', + '_:c14n3 .', + '_:c14n4 "Bob" _:c14n1 .', + '_:c14n4 _:c14n1 .' + ]; + + try { + generateMissingIdsForBlankNodes(nquadsArray); + } catch (error) { + expect(error.message).equals(` +------------------------------------------------------------------------------------------------ +Unsupported JSON-LD input detected + +After parsing the JSON-LD input, the parser detected creation of new named graphs. +The DKG does not support custom named graphs. + +Problematic Quads: + 1. "Carol" "Carol" _:b31_c14n0 . + + 2. _:b31_c14n0 . + + 3. "Bob" "Bob" _:b31_c14n1 . + + 4. _:b31_c14n1 . + + +Full Parsed N-Quads Array: +_:c14n2 "Carol" _:c14n0 . +_:c14n2 _:c14n0 . +_:c14n3 _:c14n0 . +_:c14n3 _:c14n1 . +_:c14n3 "Alice" . +_:c14n3 . +_:c14n4 "Bob" _:c14n1 . +_:c14n4 _:c14n1 . +Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs. +`); + } + }); }); From 771f1aaec47cd63e6fedd2b146af7a0b9ca01706 Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 12:56:21 +0200 Subject: [PATCH 5/8] rebase --- error-log.txt | 27 +++++++++++++++++++++++++ src/knowledge-collection-tools.js | 1 - test/knowledge-collection-tools.test.js | 1 - 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 error-log.txt diff --git a/error-log.txt b/error-log.txt new file mode 100644 index 0000000..f2f80f5 --- /dev/null +++ b/error-log.txt @@ -0,0 +1,27 @@ + +------------------------------------------------------------------------------------------------ +Unsupported JSON-LD input detected + +After parsing the JSON-LD input, the parser detected creation of new named graphs. +The DKG does not support custom named graphs. + +Problematic Quads: + 1. "Carol" "Carol" _:b31_c14n0 . + + 2. _:b31_c14n0 . + + 3. "Bob" "Bob" _:b31_c14n1 . + + 4. _:b31_c14n1 . + + +Full Parsed N-Quads Array: +_:c14n2 "Carol" _:c14n0 . +_:c14n2 _:c14n0 . +_:c14n3 _:c14n0 . +_:c14n3 _:c14n1 . +_:c14n3 "Alice" . +_:c14n3 . +_:c14n4 "Bob" _:c14n1 . +_:c14n4 _:c14n1 . +Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs. diff --git a/src/knowledge-collection-tools.js b/src/knowledge-collection-tools.js index d2cf90b..ff12f38 100644 --- a/src/knowledge-collection-tools.js +++ b/src/knowledge-collection-tools.js @@ -393,7 +393,6 @@ ${unsupportedNquads.map((q, i) => ` ${i + 1}. ${q}`).join("\n")} Full Parsed N-Quads Array: ${nquadsArray.join('\n')} -Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs. ` ); } diff --git a/test/knowledge-collection-tools.test.js b/test/knowledge-collection-tools.test.js index 040e49f..1ec4c28 100644 --- a/test/knowledge-collection-tools.test.js +++ b/test/knowledge-collection-tools.test.js @@ -866,7 +866,6 @@ _:c14n3 "Alice" . _:c14n3 . _:c14n4 "Bob" _:c14n1 . _:c14n4 _:c14n1 . -Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs. `); } }); From fa6106c98d4c7021949c11c738b2ec5feaefe595 Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 12:58:07 +0200 Subject: [PATCH 6/8] rebase --- error-log.txt | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 error-log.txt diff --git a/error-log.txt b/error-log.txt deleted file mode 100644 index f2f80f5..0000000 --- a/error-log.txt +++ /dev/null @@ -1,27 +0,0 @@ - ------------------------------------------------------------------------------------------------- -Unsupported JSON-LD input detected - -After parsing the JSON-LD input, the parser detected creation of new named graphs. -The DKG does not support custom named graphs. - -Problematic Quads: - 1. "Carol" "Carol" _:b31_c14n0 . - - 2. _:b31_c14n0 . - - 3. "Bob" "Bob" _:b31_c14n1 . - - 4. _:b31_c14n1 . - - -Full Parsed N-Quads Array: -_:c14n2 "Carol" _:c14n0 . -_:c14n2 _:c14n0 . -_:c14n3 _:c14n0 . -_:c14n3 _:c14n1 . -_:c14n3 "Alice" . -_:c14n3 . -_:c14n4 "Bob" _:c14n1 . -_:c14n4 _:c14n1 . -Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs. From 705438908a807e4a8d005d2816043d277b7a426c Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 13:04:28 +0200 Subject: [PATCH 7/8] ... --- test/knowledge-collection-tools.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/knowledge-collection-tools.test.js b/test/knowledge-collection-tools.test.js index 1ec4c28..d71b0f2 100644 --- a/test/knowledge-collection-tools.test.js +++ b/test/knowledge-collection-tools.test.js @@ -1,5 +1,4 @@ import { describe, it } from "mocha"; - import fs from 'fs'; import N3 from 'n3'; import { expect } from "chai"; import { From 784141ee1714d6a12bf567da6dd8d7c9f646a28d Mon Sep 17 00:00:00 2001 From: Marko Kostic Date: Thu, 29 May 2025 13:09:26 +0200 Subject: [PATCH 8/8] added actual uuid generation --- test/knowledge-collection-tools.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/knowledge-collection-tools.test.js b/test/knowledge-collection-tools.test.js index d71b0f2..2e45b07 100644 --- a/test/knowledge-collection-tools.test.js +++ b/test/knowledge-collection-tools.test.js @@ -1,5 +1,6 @@ import { describe, it } from "mocha"; import N3 from 'n3'; +import { v4 as uuidv4 } from "uuid"; import { expect } from "chai"; import { formatDataset, @@ -313,7 +314,7 @@ describe("groupNquadsBySubject", () => { } */ const quads = [ - ' "something"@en .', + `<${uuidv4()}> "something"@en .`, ]; const grouped = groupNquadsBySubject(quads);