diff --git a/src/edge-types/abstract-edge.ts b/src/edge-types/abstract-edge.ts index 6b5ccdc..2c85bf1 100644 --- a/src/edge-types/abstract-edge.ts +++ b/src/edge-types/abstract-edge.ts @@ -1,12 +1,13 @@ import { Node } from "../node-types/abstract-node"; -export abstract class EDGE { +export abstract class Edge { public static readonly EDGE_TYPE: string; public static readonly SOURCE_TYPES: string[]; public static readonly REFERENCE_TYPES: string[]; - + public static readonly RELATIONSHIP: string; + public readonly source: Node; public readonly reference: Node; @@ -16,12 +17,14 @@ export abstract class EDGE { } public static nodesCompatible(source: Node, reference: Node): boolean { - if (!this.SOURCE_TYPES.includes(source.TYPE)) return false; - if (!this.REFERENCE_TYPES.includes(reference.TYPE)) return false; + const sourceClass = source.constructor as typeof Node; + const referenceClass = reference.constructor as typeof Node; + if (!this.SOURCE_TYPES.includes(sourceClass.TYPE)) return false; + if (!this.REFERENCE_TYPES.includes(referenceClass.TYPE)) return false; return true; } - public static createEdge(source: Node, reference: Node): EDGE { + public static createEdge(source: Node, reference: Node): Edge { throw new Error('You must override the static createEdge method in specific edge implementations'); } diff --git a/src/edge-types/generate.ts b/src/edge-types/generate.ts new file mode 100644 index 0000000..0222e4f --- /dev/null +++ b/src/edge-types/generate.ts @@ -0,0 +1,19 @@ + +import { Node } from "../node-types/abstract-node"; +import { Edge } from "./abstract-edge"; + +export class GenerateEdge extends Edge { + + public static readonly EDGE_TYPE = "generate"; + public static readonly SOURCE_TYPES = ["claim", "evidence"]; + public static readonly REFERENCE_TYPES = ['question']; + public static readonly RELATIONSHIP = "generated-by"; + + constructor(source: Node, reference: Node) { + super(source, reference); + } + + public static createEdge(source: Node, reference: Node) { + return new GenerateEdge(source, reference); + } +} \ No newline at end of file diff --git a/src/edge-types/inform.ts b/src/edge-types/inform.ts index 21ff827..71f4a1d 100644 --- a/src/edge-types/inform.ts +++ b/src/edge-types/inform.ts @@ -1,12 +1,13 @@ import { Node } from "../node-types/abstract-node"; -import { EDGE } from "./abstract-edge"; +import { Edge } from "./abstract-edge"; -export class InformEdge extends EDGE { +export class InformEdge extends Edge { public static readonly EDGE_TYPE = "inform"; public static readonly SOURCE_TYPES = ["claim", "evidence"]; public static readonly REFERENCE_TYPES = ['question']; + public static readonly RELATIONSHIP = "informed-by"; constructor(source: Node, reference: Node) { super(source, reference); diff --git a/src/edge-types/oppose.ts b/src/edge-types/oppose.ts new file mode 100644 index 0000000..1dc7ad7 --- /dev/null +++ b/src/edge-types/oppose.ts @@ -0,0 +1,19 @@ + +import { Node } from "../node-types/abstract-node"; +import { Edge } from "./abstract-edge"; + +export class OpposeEdge extends Edge { + + public static readonly EDGE_TYPE = "oppose"; + public static readonly SOURCE_TYPES = ["claim", "evidence"]; + public static readonly REFERENCE_TYPES = ['claim']; + public static readonly RELATIONSHIP = "opposed-by"; + + constructor(source: Node, reference: Node) { + super(source, reference); + } + + public static createEdge(source: Node, reference: Node) { + return new OpposeEdge(source, reference); + } +} \ No newline at end of file diff --git a/src/edge-types/support.ts b/src/edge-types/support.ts new file mode 100644 index 0000000..8987362 --- /dev/null +++ b/src/edge-types/support.ts @@ -0,0 +1,19 @@ + +import { Node } from "../node-types/abstract-node"; +import { Edge } from "./abstract-edge"; + +export class SupportEdge extends Edge { + + public static readonly EDGE_TYPE = "support"; + public static readonly SOURCE_TYPES = ["claim", "evidence"]; + public static readonly REFERENCE_TYPES = ['claim']; + public static readonly RELATIONSHIP = "supported-by"; + + constructor(source: Node, reference: Node) { + super(source, reference); + } + + public static createEdge(source: Node, reference: Node) { + return new SupportEdge(source, reference); + } +} \ No newline at end of file