Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Formula

A formula, or store of RDF statements

Hierarchy

Index

Constructors

constructor

  • new Formula(statements?: Statement<SubjectType, PredicateType, ObjectType, GraphType>[], constraints?: readonly any[], initBindings?: readonly any[], optional?: readonly any[], opts?: FormulaOpts): Formula
  • Initializes this formula

    Parameters

    • statements: Statement<SubjectType, PredicateType, ObjectType, GraphType>[] = []

      Initial array of statements

    • constraints: readonly any[] = []

      initial array of constraints

    • initBindings: readonly any[] = []

      initial bindings used in Query

    • optional: readonly any[] = []

      optional

    • opts: FormulaOpts = {}

    Returns Formula

Properties

classOrder

classOrder: number = ClassOrder.Graph

The class order for this node

constraints

constraints: readonly any[] = []

Optional fetcher

fetcher?: Fetcher

The accompanying fetcher instance.

Is set by the fetcher when initialized.

initBindings

initBindings: readonly any[] = []

isVar

isVar: number = 0

ns

ns: (nsuri: string, factory?: RdfJsDataFactory) => (ln: string) => NamedNode = Namespace

Type declaration

    • (nsuri: string, factory?: RdfJsDataFactory): (ln: string) => NamedNode
    • Gets a namespace for the specified namespace's URI

      Parameters

      • nsuri: string

        The URI for the namespace

      • Optional factory: RdfJsDataFactory

      Returns (ln: string) => NamedNode

        • (ln: string): NamedNode
        • Gets a namespace for the specified namespace's URI

          Parameters

          • ln: string

          Returns NamedNode

optional

optional: readonly any[] = []

rdfFactory

rdfFactory: any

The factory used to generate statements and terms

statements

statements: Statement<SubjectType, PredicateType, ObjectType, GraphType>[] = []

termType

termType: "Graph" = GraphTermType

The type of node

value

value: string

The node's value

Static fromValue

fromValue: <T>(value: ValueType) => T

Type declaration

    • <T>(value: ValueType): T
    • Type parameters

      • T: FromValueReturns<any>

      Parameters

      • value: ValueType

      Returns T

Static toJS

toJS: (term: any) => string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[]

Type declaration

    • (term: any): string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[]
    • Parameters

      • term: any

      Returns string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[]

Methods

NTtoURI

  • NTtoURI(t: any): {}
  • Transform a collection of NTriple URIs into their URI strings

    Parameters

    • t: any

      Some iterable collection of NTriple URI strings

    Returns {}

    A collection of the URIs as strings todo: explain why it is important to go through NT

    add

    • add(subject: Quad_Subject | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[], predicate?: Quad_Predicate, object?: string | Term, graph?: Quad_Graph): null | number | Formula | Statement<SubjectType, PredicateType, ObjectType, GraphType>
    • Add a statement from its parts

      Parameters

      • subject: Quad_Subject | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        the first part of the statement

      • Optional predicate: Quad_Predicate

        the second part of the statement

      • Optional object: string | Term

        the third part of the statement

      • Optional graph: Quad_Graph

        the last part of the statement

      Returns null | number | Formula | Statement<SubjectType, PredicateType, ObjectType, GraphType>

    addAll

    • addAll(statements: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]): void
    • Adds all the statements to this formula

      Parameters

      • statements: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        A collection of statements

      Returns void

    addStatement

    • addStatement(statement: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>): null | number | Formula | Statement<SubjectType, PredicateType, ObjectType, GraphType>
    • Add a statment object

      Parameters

      • statement: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>

        An existing constructed statement to add

      Returns null | number | Formula | Statement<SubjectType, PredicateType, ObjectType, GraphType>

    any

    • any(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): null | Node
    • Follow link from one node, using one wildcard, looking for one

      For example, any(me, knows, null, profile) - a person I know accoring to my profile . any(me, knows, null, null) - a person I know accoring to anything in store . any(null, knows, me, null) - a person who know me accoring to anything in store .

      Parameters

      • Optional s: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional p: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional o: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional g: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      Returns null | Node

      A node which match the wildcard position, or null

    anyJS

    • anyJS(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): any
    • Gets the first JavaScript object equivalent to a node based on the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns any

    anyStatementMatching

    • anyStatementMatching(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): undefined | Statement<SubjectType, PredicateType, ObjectType, GraphType>
    • Gets the first statement that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject
      • Optional p: null | Quad_Predicate
      • Optional o: null | Quad_Object
      • Optional g: null | Quad_Graph

      Returns undefined | Statement<SubjectType, PredicateType, ObjectType, GraphType>

    anyValue

    • anyValue(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): string | void
    • Gets the value of a node that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns string | void

    bnode

    bottomTypeURIs

    • bottomTypeURIs(types: any): any
    • Finds the types in the list which have no stored subtypes These are a set of classes which provide by themselves complete information -- the other classes are redundant for those who know the class DAG.

      Parameters

      • types: any

        A map of the types

      Returns any

    collection

    compareTerm

    • compareTerm(other: Node): number

    connectedStatements

    • connectedStatements(subject: Quad_Subject, doc: Quad_Graph, excludePredicateURIs?: readonly string[]): Statement<SubjectType, PredicateType, ObjectType, GraphType>[]
    • Trace statements which connect directly, or through bnodes

      Parameters

      • subject: Quad_Subject

        The node to start looking for statments

      • doc: Quad_Graph

        The document to be searched, or null to search all documents

      • Optional excludePredicateURIs: readonly string[]

      Returns Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

      an array of statements, duplicate statements are suppresssed.

    each

    • each(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): Node[]
    • Follow links from one node, using one wildcard.

      For example, each(me, knows, null, profile) - people I know accoring to my profile . each(me, knows, null, null) - people I know accoring to anything in store . each(null, knows, me, null) - people who know me accoring to anything in store .

      Parameters

      • Optional s: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional p: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional o: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional g: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      Returns Node[]

      • An array of nodes which match the wildcard position

    equals

    findMemberURIs

    • findMemberURIs(subject: Node): UriMap
    • For thisClass or any subclass, anything which has it is its type or is the object of something which has the type as its range, or subject of something which has the type as its domain We don't bother doing subproperty (yet?)as it doesn't seeem to be used much. Get all the Classes of which we can RDFS-infer the subject is a member

      Parameters

      • subject: Node

        A named node

      Returns UriMap

    findMembersNT

    • findMembersNT(thisClass: any): MembersMap
    • For thisClass or any subclass, anything which has it is its type or is the object of something which has the type as its range, or subject of something which has the type as its domain We don't bother doing subproperty (yet?)as it doesn't seeem to be used much. Get all the Classes of which we can RDFS-infer the subject is a member

      Parameters

      • thisClass: any

      Returns MembersMap

      a hash of URIs

    findSubClassesNT

    • findSubClassesNT(subject: Node): {}
    • Get all the Classes of which we can RDFS-infer the subject is a superclass Returns a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      Parameters

      Returns {}

      • [uri: string]: boolean

    findSuperClassesNT

    • findSuperClassesNT(subject: Node): {}
    • Get all the Classes of which we can RDFS-infer the subject is a subclass

      Parameters

      • subject: Node

        The thing whose classes are to be found

      Returns {}

      a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      • [uri: string]: boolean

    findTypeURIs

    • findTypeURIs(subject: Quad_Subject): UriMap
    • Get all the Classes of which we can RDFS-infer the subject is a member todo: This will loop is there is a class subclass loop (Sublass loops are not illegal) Returns a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      Parameters

      • subject: Quad_Subject

        A subject node

      Returns UriMap

    findTypesNT

    • findTypesNT(subject: any): {}
    • Get all the Classes of which we can RDFS-infer the subject is a member todo: This will loop is there is a class subclass loop (Sublass loops are not illegal)

      Parameters

      • subject: any

        The thing whose classes are to be found

      Returns {}

      a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      • [uri: string]: boolean

    formula

    • formula(_features?: readonly string[]): Formula
    • Creates a new empty formula

      Parameters

      • Optional _features: readonly string[]

        Not applicable, but necessary for typing to pass

      Returns Formula

    fromNT

    • fromNT(str: any): any
    • Transforms an NTriples string format into a Node. The blank node bit should not be used on program-external values; designed for internal work such as storing a blank node id in an HTML attribute. This will only parse the strings generated by the various toNT() methods.

      Parameters

      • str: any

      Returns any

    hashString

    • hashString(): string

    holds

    • holds(s: any, p?: any, o?: any, g?: any): boolean
    • Returns true if this formula holds the specified statement(s)

      Parameters

      • s: any
      • Optional p: any
      • Optional o: any
      • Optional g: any

      Returns boolean

    holdsStatement

    • holdsStatement(statement: any): boolean
    • Returns true if this formula holds the specified {statement}

      Parameters

      • statement: any

      Returns boolean

    id

    • id(term: TFIDFactoryTypes): Indexable
    • Returns a unique index-safe identifier for the given term.

      Falls back to the rdflib hashString implementation if the given factory doesn't support id.

      Parameters

      • term: TFIDFactoryTypes

      Returns Indexable

    list

    • list(values: any, context: any): any
    • Used by the n3parser to generate list elements

      Parameters

      • values: any

        The values of the collection

      • context: any

        The store

      Returns any

      • The term for the statement

    sameTerm

    • sameTerm(other: Node): boolean

    serialize

    • serialize(base: any, contentType: any, provenance: any): any
    • Serializes this formula

      Parameters

      • base: any

        The base string

      • contentType: any

        The content type of the syntax to use

      • provenance: any

        The provenance URI

      Returns any

    statementsMatching

    • statementsMatching<JustOne>(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph, justOne?: boolean): Statement<SubjectType, PredicateType, ObjectType, GraphType>[]
    • Search the Store This is really a teaching method as to do this properly you would use IndexedFormula

      Type parameters

      • JustOne: boolean = false

      Parameters

      • Optional s: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional p: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional o: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional g: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      • Optional justOne: boolean

        flag - stop when found one rather than get all of them?

      Returns Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

      • An array of nodes which match the wildcard position

    substitute

    • substitute<T>(bindings: Bindings): T
    • Creates a new formula with the substituting bindings applied

      Type parameters

      Parameters

      • bindings: Bindings

        The bindings to substitute

      Returns T

    sym

    the

    • the(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): undefined | null | Node
    • Gets the node matching the specified pattern. Throws when no match could be made.

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns undefined | null | Node

    toCanonical

    • toCanonical(): string

    toNQ

    • toNQ(): string

    toNT

    • toNT(): string

    toString

    • toString(): string

    topTypeURIs

    • topTypeURIs(types: {}): {}
    • Finds the types in the list which have no stored supertypes We exclude the universal class, owl:Things and rdf:Resource, as it is information-free.

      Parameters

      • types: {}

        The types

      Returns {}

    transitiveClosure

    • transitiveClosure(seeds: BooleanMap, predicate: Quad_Predicate, inverse?: boolean): {}
    • RDFS Inference These are hand-written implementations of a backward-chaining reasoner over the RDFS axioms.

      Parameters

      • seeds: BooleanMap

        A hash of NTs of classes to start with

      • predicate: Quad_Predicate

        The property to trace though

      • Optional inverse: boolean

        Trace inverse direction

      Returns {}

      • [uri: string]: boolean

    variable

    whether

    • whether(s?: null | Quad_Subject, p?: null | Quad_Predicate, o?: null | Quad_Object, g?: null | Quad_Graph): number
    • Gets the number of statements in this formula that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns number

    Generated using TypeDoc