Jido.Character.Ontology.Renderer (Jido Character v1.0.0)

Copy Markdown View Source

Renders character schemas and data to semantic web formats.

Supports exporting:

  • OWL/RDF-XML - Schema (TBox) as OWL ontology
  • RDF Triples - Data (ABox) as N-Triples or Turtle
  • JSON-LD - Combined schema context + data for APIs

Namespace

The default namespace is http://jido.ai/character#. Override with the :namespace option.

Examples

# Export schema as OWL
Jido.Character.Ontology.Renderer.to_owl()

# Export character as RDF triples
{:ok, char} = Jido.Character.new(%{name: "Alex"})
Jido.Character.Ontology.Renderer.to_rdf(char)

# Export as JSON-LD
Jido.Character.Ontology.Renderer.to_jsonld(char)

Summary

Functions

Returns the list of ontology classes.

Returns the list of datatype properties.

Returns the list of object properties.

Exports a character as JSON-LD with embedded context.

Exports the character ontology schema as OWL/RDF-XML.

Exports a character as RDF triples.

Functions

classes()

@spec classes() :: [{atom(), String.t()}]

Returns the list of ontology classes.

datatype_properties()

@spec datatype_properties() :: [{atom(), atom(), atom(), String.t()}]

Returns the list of datatype properties.

object_properties()

@spec object_properties() :: [{atom(), atom(), atom(), String.t()}]

Returns the list of object properties.

to_jsonld(character, opts \\ [])

@spec to_jsonld(
  map(),
  keyword()
) :: map()

Exports a character as JSON-LD with embedded context.

Options

  • :namespace - Base namespace URI (default: http://jido.ai/character#)

Examples

iex> {:ok, char} = Jido.Character.new(%{name: "Alex"})
iex> jsonld = Jido.Character.Ontology.Renderer.to_jsonld(char)
iex> is_map(jsonld)
true

to_owl(opts \\ [])

@spec to_owl(keyword()) :: String.t()

Exports the character ontology schema as OWL/RDF-XML.

Options

  • :namespace - Base namespace URI (default: http://jido.ai/character#)

Examples

iex> owl = Jido.Character.Ontology.Renderer.to_owl()
iex> String.contains?(owl, "owl:Class")
true

to_rdf(character, opts \\ [])

@spec to_rdf(
  map(),
  keyword()
) :: String.t()

Exports a character as RDF triples.

Options

  • :namespace - Base namespace URI (default: http://jido.ai/character#)
  • :format - Output format: :ntriples (default) or :turtle

Examples

iex> {:ok, char} = Jido.Character.new(%{name: "Alex"})
iex> triples = Jido.Character.Ontology.Renderer.to_rdf(char)
iex> String.contains?(triples, "rdf:type")
true