Module volksdata.term

Term module.

This module contains factory functions for RDF terms and methds to handle them.

Terms can be of three types: IRIRef, Literal or BNode. The type is indicated by the volksdata.term.TYPE_* constants and each type has its own factory method.

Functions

copy (src) Copy a term.
new_bnode (data) Create a new blank node.
new_iriref (data) Create a new IRIRef from a fully-qualified URI.
new_iriref (data) Create a new IRIRef from a namespace-prefixed URI.
new_iriref_abs (root, iri) Create a new absolute IRIRef from a root and a relative URI.
new_iriref_rel (root, iri) Create a new IRIRef from a path relative to a root URI.
new_lit (data, dtype, lang) Create a new literal with optional data type or language tag.

Class volksdata.Term

volksdata.term.data Term data.
volksdata.term.datatype Literal data type (as a URI string).
volksdata.term.frag IRIRef fragment.
volksdata.term.hash Term hash.
volksdata.term.lang Literal language tag.
volksdata.term.path IRIRef path.
volksdata.term.prefix IRIRef prefix.
volksdata.term.type Term type.
volksdata.term:__eq () Equality operator (==).
volksdata.term:__tostring (the) String representation of a term.

Class volksdata.TermSet

volksdata.termset:__len () Term set size in number of terms contained.
volksdata.termset:contains () Whether a term set contains a triple.
volksdata.termset:iter () Iterate over a term set.

Class volksdata.LinkMap

volksdata.linkmap:iter (it, copy) Iterate over a link map.


Functions

copy (src)
Copy a term.

Parameters:

  • src Term Term to copy.

Returns:

    Term
new_bnode (data)
Create a new blank node.

Parameters:

  • data string Blank node label.

Returns:

    Term
new_iriref (data)
Create a new IRIRef from a fully-qualified URI.

Parameters:

  • data string Fully-qualified URI.

Returns:

    Term
new_iriref (data)
Create a new IRIRef from a namespace-prefixed URI.

The namespace prefix must exist in the namespace map. Note that the term is internally normalized after creation, and no information is retained about whether the original input was fully qualified; hence, a term created from a fully-qualified URI with new_iriref and one created with this function are effectively equivalent and indistinguishable.

Parameters:

  • data string Fully-qualified URI.

Returns:

    Term
new_iriref_abs (root, iri)
Create a new absolute IRIRef from a root and a relative URI.

If the provided URI is already an absolute URI, the result is semantically identical to the input. If the relative URI begins with a '/', the resulting URI is relative to the web root of the root URI. I.e. if a root URI has a path after the webroot, it is ignored. Otherwise, the resulting URI is relative to the full root string.

Parameters:

  • root Term Root of the URI.
  • iri Term Relative URI.

Returns:

    Term
new_iriref_rel (root, iri)
Create a new IRIRef from a path relative to a root URI.

Parameters:

  • root Term Root of the new relative URI.
  • iri Term Absolute URI.

Returns:

    Term
new_lit (data, dtype, lang)
Create a new literal with optional data type or language tag.

Note: data type and language tag are exclusive. If both are specified, data type has precedence. If both are nil, data type is set to the default (xsd:string).

Parameters:

  • data string String to create the literal from.
  • dtype Term Data type for the literal. See note.
  • lang string Language tag. See note.

Returns:

    Term New literal term.

Class volksdata.Term

Term class.
volksdata.term.data
Term data.

This is the URI string for a IRIRef, the plain (untyped and untagged) content of a literal term, or a blank node label.

  • data
volksdata.term.datatype
Literal data type (as a URI string).
  • datatype
volksdata.term.frag
IRIRef fragment.

For an IRIRef, this is the part of the URI following and not including the hash sign (#).

  • frag
volksdata.term.hash
Term hash.

This is the checksum of the internal serialization of a term.

  • hash
volksdata.term.lang
Literal language tag.
  • lang
volksdata.term.path
IRIRef path.

For an IRIRef, this is the path of the IRI relative to the web root. For a URN, such as urn:myns:myid, it would be myns:myid.

  • path
volksdata.term.prefix
IRIRef prefix.

For an IRIRef, this is the protocol + domain name part of a URI.

  • prefix
volksdata.term.type
Term type.
  • type
volksdata.term:__eq ()
Equality operator (==).

Two terms are considered equal if they are of the same type and have the same data and metadata. Internally, this comparison is done by comparing the checksums of their serialized version (an internal format, not RDF).

Returns:

    boolean
volksdata.term:__tostring (the)
String representation of a term.

This is a valid N3 serialization.

Parameters:

  • the Term term to serialize.

Returns:

    string

Class volksdata.TermSet

Term set class.

Unordered set of terms that can be iterated over and looked up.

volksdata.termset:__len ()
Term set size in number of terms contained.

Returns:

    integer
volksdata.termset:contains ()
Whether a term set contains a triple.

Returns:

    boolean
volksdata.termset:iter ()
Iterate over a term set.

Returns:

    function Iterator function.

Class volksdata.LinkMap

Link map class.

A link map represents a connection network in a hierarchical fashion. It contains a table of terms, each related to a term set, and it offers a top-level function to iterate over the linked terms and get the term sets, which are themselves iterable.

volksdata.linkmap:iter (it, copy)
Iterate over a link map.

Internally this function creates a LMapIterator, which is used as the upvalue for lmapiternext(). The iterator is garbage collected at the end of the iteration loop, the link map can be reused.

Parameters:

  • it LinkMapIterator Iterator handle.
  • copy bool If false (default), the iteration yields the linked term, a term set iterator, and its size. This avoids copying the term set into a new table, but the returned object can only be iterated once, and random access via contains is not allowed. If true, the iteration yields the linked term and a full term set with a copy of the term set.
generated by LDoc 1.5.0 Last updated 2026-01-02 15:30:28