Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Formula

A formula, or store of RDF statements

Hierarchy

Index

Constructors

constructor

  • new Formula(statements?: Quad[], constraints?: ReadonlyArray<any>, initBindings?: ReadonlyArray<any>, optional?: ReadonlyArray<any>, opts?: FormulaOpts): Formula
  • Initializes this formula

    constructor

    Parameters

    • Optional statements: Quad[]

      Initial array of statements

    • Optional constraints: ReadonlyArray<any>

      initial array of constraints

    • Optional initBindings: ReadonlyArray<any>

      initial bindings used in Query

    • Optional optional: ReadonlyArray<any>

      optional

    • Default value opts: FormulaOpts = {}

    Returns Formula

Properties

classOrder

classOrder: number = ClassOrder.Graph

constraints

constraints: ReadonlyArray<any>

The additional constraints

Optional fetcher

fetcher: Fetcher

The accompanying fetcher instance.

Is set by the fetcher when initialized.

initBindings

initBindings: ReadonlyArray<any>

isVar

isVar: number = 0

ns

ns: Namespace = Namespace

A namespace for the specified namespace's URI

param

The URI for the namespace

optional

optional: ReadonlyArray<any>

rdfFactory

rdfFactory: any

The factory used to generate statements and terms

statements

statements: Quad[]

The stored statements

termType

termType: "Graph" = GraphTermType

value

value: string

The node's value

Static fromValue

fromValue: function

Type declaration

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>

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

  • Add a statement from its parts

    Parameters

    Returns number

addAll

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

    Parameters

    • statements: Quad[]

      A collection of statements

    Returns void

addStatement

  • addStatement(statement: Quad): number
  • Add a statment object

    Parameters

    • statement: Quad

      An existing constructed statement to add

    Returns number

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

  • Gets the value of a node that matches the specified pattern

    Parameters

    Returns string | void

bnode

  • deprecated

    use {this.rdfFactory.blankNode} instead

    Parameters

    • Optional id: undefined | string

    Returns BlankNode

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
  • Compares this node with another

    see

    {equals} to check if two nodes are equal

    Parameters

    • other: Node

      The other node

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

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

  • Test whether this formula is equals to {other}

    Parameters

    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

  • formula(_features?: ReadonlyArray<string>): Formula
  • Creates a new empty formula

    Parameters

    • Optional _features: ReadonlyArray<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 | 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
  • Returns true if this formula holds the specified {statement}

    Parameters

    • statement: any

    Returns 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

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

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

    Type parameters

    • JustOne: boolean

    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

    • 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

  • deprecated

    use {rdfFactory.namedNode} instead

    Parameters

    • uri: string
    • Optional name: any

    Returns NamedNode

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

variable

  • variable(name: string): Variable
  • Gets a new variable

    Parameters

    • name: string

      The variable's name

    Returns Variable

whether

  • Gets the number of statements in this formula that matches the specified pattern

    Parameters

    Returns number