Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IndexedFormula

Indexed Formula aka Store

Hierarchy

Index

Constructors

constructor

Properties

HTTPRedirects

HTTPRedirects: Quad[]

Redirections we got from HTTP

Optional _existentialVariables

_existentialVariables: BlankNode[]

Optional _universalVariables

_universalVariables: TFNamedNode[]

aliases

aliases: any[]

Reverse mapping to redirection: aliases for this

classActions

classActions: object

Map of iri predicates to functions to call when adding { s type X }

Type declaration

  • [k: string]: Function[]

classOrder

classOrder: number = ClassOrder.Graph

constraints

constraints: ReadonlyArray<any>

The additional constraints

features

features: FeaturesType

Optional fetcher

fetcher: Fetcher

The accompanying fetcher instance.

Is set by the fetcher when initialized.

index

index: [Quad[], Quad[], Quad[], Quad[]]

initBindings

initBindings: ReadonlyArray<any>

isVar

isVar: number = 0

namespaces

namespaces: object

Dictionary of namespace prefixes

Type declaration

  • [key: string]: string

ns

ns: Namespace = Namespace

A namespace for the specified namespace's URI

param

The URI for the namespace

objectIndex

objectIndex: Quad[]

Array of statements with this X as object

optional

optional: ReadonlyArray<any>

predicateIndex

predicateIndex: Quad[]

Array of statements with this X as predicate

propertyActions

propertyActions: object

Map of iri predicates to functions to call when getting statement with {s X o}

Type declaration

  • [k: string]: Function[]

rdfFactory

rdfFactory: any

The factory used to generate statements and terms

redirections

redirections: any[]

Redirect to lexically smaller equivalent symbol

statements

statements: Quad[]

The stored statements

subjectIndex

subjectIndex: Quad[]

Array of statements with this X as subject

termType

termType: "Graph" = GraphTermType

Optional updater

updater: UpdateManager

An UpdateManager initialised to this store

value

value: string

The node's value

whyIndex

whyIndex: Quad[]

Array of statements with X as provenance

Static fromValue

fromValue: function

Type declaration

Static handleRDFType

handleRDFType: Function

Static toJS

toJS: function

Type declaration

    • (term: any): Date | Number | string | boolean | object | Array<Date | Number | string | boolean | object>
    • Parameters

      • term: any

      Returns Date | Number | string | boolean | object | Array<Date | Number | string | boolean | object>

Accessors

length

  • get length(): number
  • Returns the number of statements contained in this IndexedFormula. (Getter proxy to this.statements). Usage:

       var kb = rdf.graph()
       kb.length  // -> 0

    Returns number

Static defaultGraphURI

  • get defaultGraphURI(): string
  • Gets the URI of the default graph

    Returns string

Methods

NTtoURI

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

    Parameters

    • t: any

      Some iterable collection of NTriple URI strings

    Returns object

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

add

  • Adds a triple (quad) to the store.

    Parameters

    • subj: Quad_Subject | Quad | Quad[] | Statement | Statement[]

      The thing about which the fact a relationship is asserted. Also accepts a statement or an array of Statements.

    • Optional pred: Quad_Predicate

      The relationship which is asserted

    • Optional obj: Term | string

      The object of the relationship, e.g. another thing or avalue. If passed a string, this will become a literal.

    • Optional why: Quad_Graph

      The document in which the triple (S,P,O) was or will be stored on the web

    Returns Quad | null | IndexedFormula

    The statement added to the store, or the store

addAll

  • addAll(statements: Quad[]): void
  • Adds all the statements to this formula

    Parameters

    • statements: Quad[]

      A collection of statements

    Returns void

addDataCallback

  • addDataCallback(cb: function): void
  • Add a callback which will be triggered after a statement has been added to the store.

    Parameters

    • cb: function
        • Parameters

          Returns void

    Returns void

addStatement

  • addStatement(st: Quad): number

allAliases

  • allAliases(x: NamedNode): NamedNode[]
  • Return all equivalent URIs by which this is known

    Parameters

    • x: NamedNode

      A named node

    Returns NamedNode[]

any

  • 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: Quad_Subject | null

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

    • Optional p: Quad_Predicate | null

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

    • Optional o: Quad_Object | null

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

    • Optional g: Quad_Graph | null

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

    Returns Term | null

    A node which match the wildcard position, or null

anyJS

  • Gets the first JavaScript object equivalent to a node based on the specified pattern

    Parameters

    Returns any

anyStatementMatching

anyValue

applyPatch

  • applyPatch(patch: object, target: TFNamedNode, patchCallback: function): void
  • Apply a set of statements to be deleted and to be inserted

    Parameters

    • patch: object

      The set of statements to be deleted and to be inserted

    • target: TFNamedNode

      The name of the document to patch

    • patchCallback: function

      Callback to be called when patching is complete

        • (errorString?: undefined | string): void
        • Parameters

          • Optional errorString: undefined | string

          Returns void

    Returns 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

canon

  • Returns the symbol with canonical URI as smushed

    Parameters

    • term: Term

      An RDF node

    Returns Term

check

  • check(): void
  • Checks this formula for consistency

    Returns void

checkStatementList

  • checkStatementList(sts: ReadonlyArray<Quad>, from?: undefined | number): boolean | void
  • Checks a list of statements for consistency

    Parameters

    • sts: ReadonlyArray<Quad>

      The list of statements to check

    • Optional from: undefined | number

      An index with the array ['subject', 'predicate', 'object', 'why']

    Returns boolean | void

close

collection

compareTerm

  • compareTerm(u1: Term, u2: Term): number

connectedStatements

  • 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: ReadonlyArray<string>

    Returns Quad[]

    an array of statements, duplicate statements are suppresssed.

copyTo

  • replaces @template with @target and add appropriate triples removes no triples by default and is a one-direction replication

    Parameters

    • template: Quad_Subject

      node to copy

    • target: Quad_Subject

      node to copy to

    • Optional flags: Array<"two-direction" | "delete">

      Whether or not to do a two-directional copy and/or delete triples

    Returns void

declareExistential

  • N3 allows for declaring blank nodes, this function enables that support

    Parameters

    • x: BlankNode

      The blank node to be declared, supported in N3

    Returns BlankNode

each

  • 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: Quad_Subject | null

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

    • Optional p: Quad_Predicate | null

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

    • Optional o: Quad_Object | null

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

    • Optional g: Quad_Graph | null

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

    Returns Term[]

    • An array of nodes which match the wildcard position

equals

equate

  • equate(u1in: Term, u2in: Term): boolean
  • Simplify graph in store when we realize two identifiers are equivalent We replace the bigger with the smaller.

    Parameters

    • u1in: Term

      The first node

    • u2in: Term

      The second node

    Returns boolean

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): object
  • 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 object

    • [uri: string]: boolean

findSuperClassesNT

  • findSuperClassesNT(subject: Node): object
  • 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 object

    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

  • 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

    Returns UriMap

findTypesNT

  • findTypesNT(subject: any): object
  • 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 object

    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

  • Creates a new empty indexed formula Only applicable for IndexedFormula, but TypeScript won't allow a subclass to override a property

    Parameters

    • features: FeaturesType

      The list of features

    Returns IndexedFormula

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 | any[], p?: any, o?: any, g?: any): boolean
  • Returns true if this formula holds the specified statement(s)

    Parameters

    • s: any | any[]
    • Optional p: any
    • Optional o: any
    • Optional g: any

    Returns boolean

holdsStatement

  • holdsStatement(statement: any): boolean

id

  • 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

    Returns Indexable

initPropertyActions

  • initPropertyActions(features: FeaturesType): void
  • Parameters

    • features: FeaturesType

    Returns void

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

match

  • Returns any quads matching the given arguments. Standard RDFJS spec method for Source objects, implemented as an alias to statementsMatching()

    Parameters

    Returns Quad[]

mentionsURI

  • mentionsURI(uri: string): boolean
  • Find out whether a given URI is used as symbol in the formula

    Parameters

    • uri: string

      The URI to look for

    Returns boolean

newExistential

  • newExistential(uri: string): Term
  • Existentials are BNodes - something exists without naming

    Parameters

    • uri: string

      An URI

    Returns Term

newPropertyAction

newUniversal

  • newUniversal(uri: string): TFNamedNode
  • Creates a new universal node Universals are Variables

    Parameters

    • uri: string

      An URI

    Returns TFNamedNode

nextSymbol

  • nextSymbol(doc: TFNamedNode): TFNamedNode
  • Find an unused id for a file being edited: return a symbol (Note: Slow iff a lot of them -- could be O(log(k)) )

    Parameters

    • doc: TFNamedNode

      A document named node

    Returns TFNamedNode

query

  • query(myQuery: Query, callback: function, dummy?: Fetcher | null, onDone?: undefined | function): void
  • Query this store asynchronously, return bindings in callback

    Parameters

    • myQuery: Query

      The query to be run

    • callback: function

      Function to call when bindings

    • Optional dummy: Fetcher | null

      OBSOLETE - do not use this

    • Optional onDone: undefined | function

      OBSOLETE - do not use this

    Returns void

querySync

  • querySync(myQuery: Query): any[]
  • Query this store synchronously and return bindings

    Parameters

    • myQuery: Query

      The query to be run

    Returns any[]

remove

  • Removes one or multiple statement(s) from this formula

    Parameters

    • st: Quad | Quad[]

      A Statement or array of Statements to remove

    Returns IndexedFormula

removeDocument

removeMany

  • Remove all statements matching args (within limit) *

    Parameters

    • Optional subj: Quad_Subject | null

      The subject

    • Optional pred: Quad_Predicate | null

      The predicate

    • Optional obj: Quad_Object | null

      The object

    • Optional why: Quad_Graph | null

      The graph that contains the statement

    • Optional limit: undefined | number

      The number of statements to remove

    Returns void

removeMatches

removeStatement

  • Remove a particular statement object from the store

    Parameters

    • st: Quad

      a statement which is already in the store and indexed. Make sure you only use this for these. Otherwise, you should use remove() above.

    Returns IndexedFormula

removeStatements

replaceWith

sameTerm

  • sameTerm(other: Node): boolean

sameThings

  • sameThings(x: NamedNode, y: NamedNode): boolean
  • Compare by canonical URI as smushed

    Parameters

    • x: NamedNode

      A named node

    • y: NamedNode

      Another named node

    Returns 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

setPrefixForURI

  • setPrefixForURI(prefix: string, nsuri: string): void
  • Parameters

    • prefix: string
    • nsuri: string

    Returns void

statementsMatching

  • Search the Store

    ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS!

    Parameters

    • Optional subj: Quad_Subject | null

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

    • Optional pred: Quad_Predicate | null

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

    • Optional obj: Quad_Object | null

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

    • Optional why: Quad_Graph | null

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

    • Optional justOne: undefined | false | true

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

    Returns Quad[]

    An array of nodes which match the wildcard position

substitute

sym

the

  • Gets the node matching the specified pattern. Throws when no match could be made.

    Parameters

    Returns Term | null | undefined

toCanonical

  • toCanonical(): string

toNQ

  • toNQ(): string

toNT

  • toNT(): string

toString

  • toString(): string

topTypeURIs

  • topTypeURIs(types: object): object
  • 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: object

      The types

      • [id: string]: string | RDFlibNamedNode

    Returns object

    • [id: string]: string | RDFlibNamedNode

transitiveClosure

  • transitiveClosure(seeds: BooleanMap, predicate: Quad_Predicate, inverse?: undefined | false | true): object
  • 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: undefined | false | true

      Trace inverse direction

    Returns object

    • [uri: string]: boolean

uris

  • A list of all the URIs by which this thing is known

    Parameters

    Returns string[]

variable

  • variable(name: string): Variable

whether