-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: problem with assumption that "quoted triples" are quads #35
base: master
Are you sure you want to change the base?
Changes from all commits
190ee96
e0854d6
2f435a4
03a83f6
0c9df08
6c74395
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,7 +10,7 @@ | |||||
* @see DefaultGraph | ||||||
* @see BaseQuad | ||||||
*/ | ||||||
export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph | BaseQuad; | ||||||
export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph | BaseQuad | BaseTriple; | ||||||
|
||||||
/** | ||||||
* Contains an IRI. | ||||||
|
@@ -128,12 +128,12 @@ export interface DefaultGraph { | |||||
} | ||||||
|
||||||
/** | ||||||
* The subject, which is a NamedNode, BlankNode or Variable. | ||||||
* The subject, which is a NamedNode, BlankNode, Variable, or a quoted triple. | ||||||
* @see NamedNode | ||||||
* @see BlankNode | ||||||
* @see Variable | ||||||
*/ | ||||||
export type Quad_Subject = NamedNode | BlankNode | Quad | Variable; | ||||||
export type Quad_Subject = NamedNode | BlankNode | Triple | Variable; | ||||||
|
||||||
/** | ||||||
* The predicate, which is a NamedNode or Variable. | ||||||
|
@@ -143,13 +143,13 @@ export type Quad_Subject = NamedNode | BlankNode | Quad | Variable; | |||||
export type Quad_Predicate = NamedNode | Variable; | ||||||
|
||||||
/** | ||||||
* The object, which is a NamedNode, Literal, BlankNode or Variable. | ||||||
* The object, which is a NamedNode, Literal, BlankNode, Variable, or a quoted triple. | ||||||
* @see NamedNode | ||||||
* @see Literal | ||||||
* @see BlankNode | ||||||
* @see Variable | ||||||
*/ | ||||||
export type Quad_Object = NamedNode | Literal | BlankNode | Quad | Variable; | ||||||
export type Quad_Object = NamedNode | Literal | BlankNode | Triple | Variable; | ||||||
|
||||||
/** | ||||||
* The named graph, which is a DefaultGraph, NamedNode, BlankNode or Variable. | ||||||
|
@@ -233,6 +233,13 @@ export interface Quad extends BaseQuad { | |||||
equals(other: Term | null | undefined): boolean; | ||||||
} | ||||||
|
||||||
export interface BaseTriple extends Omit<BaseQuad, 'graph' | 'termType'> { | ||||||
termType: 'QuotedTriple'; | ||||||
} | ||||||
export interface Triple extends Omit<Quad, 'graph' | 'termType'> { | ||||||
termType: 'QuotedTriple'; | ||||||
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.
Suggested change
|
||||||
} | ||||||
|
||||||
/** | ||||||
* A factory for instantiating RDF terms and quads. | ||||||
*/ | ||||||
|
@@ -286,5 +293,5 @@ export interface DataFactory<OutQuad extends BaseQuad = Quad, InQuad extends Bas | |||||
* @return A new instance of Quad. | ||||||
* @see Quad | ||||||
*/ | ||||||
quad(subject: InQuad['subject'], predicate: InQuad['predicate'], object: InQuad['object'], graph?: InQuad['graph']): OutQuad; | ||||||
quad(subject: InQuad['subject'] | InQuad, predicate: InQuad['predicate'], object: InQuad['object'] | InQuad, graph?: InQuad['graph']): OutQuad; | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||
import { BlankNode, DataFactory, Dataset, DatasetCore, DatasetCoreFactory, DatasetFactory, DefaultGraph, Literal, | ||||||
NamedNode, Quad, BaseQuad, Sink, Source, Store, Stream, Term, Variable, Quad_Graph } from "."; | ||||||
NamedNode, Quad, BaseQuad, Sink, Source, Store, Stream, Term, Variable, Quad_Graph, Triple, BaseTriple } from "."; | ||||||
import { EventEmitter } from "events"; | ||||||
|
||||||
function test_terms() { | ||||||
|
@@ -54,6 +54,32 @@ function test_terms() { | |||||
let defaultGraphEqual: boolean = defaultGraph.equals(someTerm); | ||||||
defaultGraphEqual = defaultGraph.equals(null); | ||||||
defaultGraphEqual = defaultGraph.equals(undefined); | ||||||
|
||||||
const term: Term = <any> {}; | ||||||
let term2: Term | undefined | ||||||
switch (term.termType) { | ||||||
case 'Quad': | ||||||
term2 = <BaseQuad>term; | ||||||
break; | ||||||
case 'QuotedTriple': | ||||||
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.
Suggested change
|
||||||
term2 = <BaseTriple>term; | ||||||
break; | ||||||
case 'NamedNode': | ||||||
term2 = <NamedNode>term; | ||||||
break; | ||||||
case 'Literal': | ||||||
term2 = <Literal>term; | ||||||
break; | ||||||
case 'BlankNode': | ||||||
term2 = <BlankNode>term; | ||||||
break; | ||||||
case 'Variable': | ||||||
term2 = <Variable>term; | ||||||
break; | ||||||
case 'DefaultGraph': | ||||||
term2 = <DefaultGraph>term; | ||||||
break; | ||||||
} | ||||||
} | ||||||
|
||||||
function test_quads() { | ||||||
|
@@ -113,11 +139,15 @@ function test_datafactory_star() { | |||||
); | ||||||
|
||||||
// Decompose the triple | ||||||
if (quadBobAgeCertainty.subject.termType === 'Quad') { | ||||||
const quadBobAge2: Quad = quadBobAgeCertainty.subject; | ||||||
if (quadBobAgeCertainty.subject.termType === 'QuotedTriple') { | ||||||
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.
Suggested change
|
||||||
const quadBobAge2: Triple = quadBobAgeCertainty.subject; | ||||||
|
||||||
const equalToSelf: boolean = quadBobAge2.equals(quadBobAge); | ||||||
const notEqualToOtherType: boolean = quadBobAge2.equals(dataFactory.namedNode('ex:something:else')); | ||||||
|
||||||
const dataset: DatasetCore = <any> {}; | ||||||
// @ts-expect-error: triple is not assignable to quad. It has no graph property | ||||||
dataset.add(quadBobAge2); | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -137,11 +167,15 @@ function test_datafactory_star_basequad() { | |||||
); | ||||||
|
||||||
// Decompose the triple | ||||||
if (quadBobAgeCertainty.subject.termType === 'Quad') { | ||||||
const quadBobAge2: BaseQuad = quadBobAgeCertainty.subject; | ||||||
if (quadBobAgeCertainty.subject.termType === 'QuotedTriple') { | ||||||
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.
Suggested change
|
||||||
const quadBobAge2: BaseTriple = quadBobAgeCertainty.subject; | ||||||
|
||||||
const equalToSelf: boolean = quadBobAge2.equals(quadBobAge); | ||||||
const notEqualToOtherType: boolean = quadBobAge2.equals(dataFactory.namedNode('ex:something:else')); | ||||||
|
||||||
const dataset: DatasetCore<BaseQuad> = <any> {}; | ||||||
// @ts-expect-error: triple is not assignable to quad. It has no graph property | ||||||
dataset.add(quadBobAge2); | ||||||
} | ||||||
} | ||||||
|
||||||
|
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.