Class Formula

A formula, or store of RDF statements

Hierarchy (view full)

Constructors

  • 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: number = ClassOrder.Graph

The class order for this node

constraints: readonly any[] = []

initial array of constraints

fetcher?: Fetcher

The accompanying fetcher instance.

Is set by the fetcher when initialized.

initBindings: readonly any[] = []

initial bindings used in Query

isVar: number = 0
ns: ((nsuri, factory?) => ((ln) => NamedNode)) = Namespace

A namespace for the specified namespace's URI

Type declaration

    • (nsuri, factory?): ((ln) => NamedNode)
    • Parameters

      • nsuri: string

        The URI for the namespace

      • Optional factory: RdfJsDataFactory

      Returns ((ln) => NamedNode)

        • (ln): NamedNode
        • Parameters

          • ln: string

          Returns NamedNode

optional: readonly any[] = []

optional

rdfFactory: any

The factory used to generate statements and terms

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

Initial array of statements

termType: "Graph" = GraphTermType

The type of node

value: string

The node's value

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

Type declaration

    • <T>(value): T
    • Type Parameters

      • T extends FromValueReturns

      Parameters

      • value: ValueType

      Returns T

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

Type declaration

    • (term): 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

  • 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 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 | Statement<SubjectType, PredicateType, ObjectType, GraphType> | Formula

    • Adds all the statements to this formula

      Parameters

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

        A collection of statements

      Returns void

    • Add a statment object

      Parameters

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

        An existing constructed statement to add

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

    • 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

    • 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

    • 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>

    • 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

    • 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

    • 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.

    • 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
    • Test whether this formula is equals to {other}

      Parameters

      Returns boolean

    • 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

    • 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

    • 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;
      }

      • [uri: string]: boolean
    • 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 {
          [uri: string]: boolean;
      }

      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
    • 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

    • 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 {
          [uri: string]: boolean;
      }

      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
    • Creates a new empty formula

      Parameters

      • Optional _features: readonly string[]

        Not applicable, but necessary for typing to pass

      Returns Formula

    • 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

    • Returns true if this formula holds the specified statement(s)

      Parameters

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

      Returns boolean

    • Returns true if this formula holds the specified {statement}

      Parameters

      • statement: any

      Returns boolean

    • 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

    • 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
    • Serializes this formula

      Parameters

      • base: any

        The base string

      • contentType: any

        The content type of the syntax to use

      • provenance: any

        The provenance URI

      • Optional options: any

        options to pass to the serializer, as defined in serialize method

      Returns undefined | string

    • Search the Store This is really a teaching method as to do this properly you would use IndexedFormula

      Type Parameters

      • JustOne extends 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
    • Creates a new formula with the substituting bindings applied

      Type Parameters

      Parameters

      • bindings: Bindings

        The bindings to substitute

      Returns T

    • 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

    • 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: {
            [id: string]: string | NamedNode;
        }

        The types

      Returns {
          [id: string]: string | NamedNode;
      }

    • 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;
      }

      • [uri: string]: boolean
    • 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