Defined known edge types
This commit is contained in:
parent
a4daf1c3e0
commit
42bf560f9f
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue